-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variances in FixedEffectsModel are Scaled Oddly #374
Comments
Hi Will, I spent some time looking into this today, and I think what's happening is that the sample size of the "sleepstudy" dataset is too small for our approximation to work correctly. We approximate the posterior distribution of the coefficients by fitting a Gaussian -- so if there aren't enough samples, the distribution may not be Gaussian enough for the approximation to match the observed variance (I assume lme4 is bootstrapping this). If you use the larger "InstEval" dataset, the numbers are much closer: data(InstEval)
m <- lm(y ~ service, data=InstEval)
summary(m) R lm results:
Photon-ML Results:
These still aren't exactly the same, but they're much closer. In our tests with large datasets, the numbers always match within 0.1% or so. Just to reiterate: The coefficient variance approximation in Photon assumes a very large dataset (let's say at least 50,000 examples), so that the posterior distribution of coefficients is roughly Gaussian. |
Thank you for the reply @joshvfleming! I loaded up the InstEval data set into my script and I'm still getting some odd results. For your photon-ml results, can you try adding a random effects term in there as well? And are you using the GameEstimator or something else? Thank you for your guidance! data(InstEval)
# Coercing these to numeric
InstEval$deptNum <- as.numeric(InstEval$dept)
InstEval$serviceNum <- as.numeric(InstEval$service)
m <- lmer(y ~ serviceNum + (serviceNum | deptNum), data=InstEval)
summary(m) Results from R
Random effects:
Results from my Photon-ML script: Running it with some different hyperparameters gets me closer to the coefficients (so not worried about that) but the variance is still extremely small. Fixed Effects:
Random Effects:
|
It looks like what's happening there is that To sum up -- the variances that Photon produces are a decent approximation to the posterior of each individual (e.g. fixed effect) model, but they're not "correct" in context of the larger additive model. I suppose we could add a post-processing step to compute the joint variances, but as I mentioned before, this would become impractical really fast. I am open to suggestions, though. 😃 |
Ah! Okay. This makes sense. I forgot the A in GAME ;-) Thank you for that clarification! I would be interested in pursuing the post-processing step but I wouldn't know where to start in the codebase. Any pointers on how I could extract the covariance matrix after the models have been trained? It looks like If only there were a simple way of just aggregating the variances and normalizing! Maybe I just need to try using the ModelDiagnostics for coefficient importance instead. Thank you for all your help and guidance, Josh! |
Hello Will - just following up that there's no way right now to pull the covariance matrix out after model training. However, you're always free to contribute any changes you make to Photon ML for your own pusposes. I'm going to close this issue, please re-open it if we can further assist you. |
lme4-photon-sleep.zip
I'm attempting to build Std. Err., T value, and P value into the results of a photon-ml run but the reported variances are incredibly small relative to the same analysis done in R's lme4.
LME4 Results
Photon-ML Results
Assuming std error is calculated as
sqrt(variance)
, I'm nowhere near it../gradlew build -x integTest
model.coefficients.variancesOption
.Any suggestions from the community on correcting the variances reported?
Thank you for any guidance!
The text was updated successfully, but these errors were encountered: