I am trying to get least square means or adjusted means in Julia from my dataset.
I’ve been using ‘emmeans’ in R or ‘lsmean’ in SAS, equivalently.
Would there be any Julia package or way to do it in Julia?
I am not sure what does are — generally, arithmetic means minimize squared deviations, so
Statistics.mean should be fine.
Thank you for your reply!
Least Squares Mean is a mean estimated from a linear model, adjusted for other covariates in the model. It is easy to find relevant packages in other languages but I can’t find any in Julia.
This sounds like a simple linear regression (OLS)? In that case you should probably look at GLM.jj
Looking at the SAS page for LSMEANS, I don’t believe we have anything that does this in GLM.jl. It seems like you could construct it with what GLM returns though.
(I’m also not familiar with this concept. Looks a bit like “marginal effects at the mean” but then again not quite.)
Interesting - a bit of googling seems to suggest that this is something that SAS invented? Here’s a CrossValidated answer that suggests lsmeans could be obtained using GLM and the
predict function: https://stats.stackexchange.com/questions/284121/are-lsmeans-calculated-from-predicted-values
Also note that it’s easy to call R from Julia using RCall.jl, so you can keep using emmeans through R (and shifting your data over with the
@rput macro), or at least try to create your adjusted means from a linear model fit with GLM.jl and then compare to the R results easily.
I guess RCall may be a good solution for now!