Least Square Means or Adjusted Means

Hello,
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?
Thank you.

1 Like

I am not sure what does are — generally, arithmetic means minimize squared deviations, so Statistics.mean should be fine.

1 Like

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. :frowning:

This sounds like a simple linear regression (OLS)? In that case you should probably look at GLM.jj

3 Likes

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.)

1 Like

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: Are LSMeans calculated from Predicted Values? - Cross Validated

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.

3 Likes

Thanks :slight_smile:

Thanks :slight_smile:
I guess RCall may be a good solution for now!