Comments (2)
Here's some additional info in case it's helpful:
- I fit the original model, then used
robcov
with cluster = individual site and triedanova.
Got an error that led to trying cluster = site type. (That error ended up being related to needing a highertol
.) - When I tried cluster = site type (dichotomous), there was no warning or error, but the results had negative SS and F statistics and p-values of 1.0 for variables that were highly significant in the original model.
- The same issues were seen when using
fit.mult.impute(..., fitter = ols)
on the same data.
from rms.
I modified your code to expose the problem a bit more:
set.seed(56)
for(nsites in 7:2) {
cat('nsites:', nsites, '\n')
df <- data.frame(y = rnorm(n = 100),
x1 = rnorm(n = 100),
x2 = rnorm(mean = 5, sd = 0.5, n = 100),
site = sample(LETTERS[1:nsites], size = 100, replace = TRUE))
f <- ols(y ~ rcs(x1, 3) + rcs(x2, 3), data = df, x = TRUE, y = TRUE)
g <- robcov(f, cluster = df$site)
print(anova(g))
}
You'll see that it's ok for 7, 6, 5 sites but is singular with 4 sites. [Don't mess with tol to try to avoid the problem.]
Just as with a random effects model you must have at least 3 clusters, and more are recommended, there is a limit to how few clusters you can use when using the sandwich estimator. This does need to be better understood though.
But the results are dataset dependent. If we fix x1 and x2 to be the same no matter how site is computed, and set up to be able to also use bootcov
we get:
afun <- robcov
set.seed(56)
df <- data.frame(y = rnorm(n = 100),
x1 = rnorm(n = 100),
x2 = rnorm(mean = 5, sd = 0.5, n = 100))
for(nsites in 7:2) {
cat('nsites:', nsites, '\n')
df$site <- sample(LETTERS[1:nsites], size = 100, replace = TRUE)
f <- ols(y ~ rcs(x1, 3) + rcs(x2, 3), data = df, x = TRUE, y = TRUE)
g <- afun(f, cluster=df$site)
print(anova(g))
}
Things work mathematically until nsites=4 but the anova doesn't look quite right with nsites < 6.
If we instead use afun <- function(...) bootcov(..., B=500)
, results are mathematically OK for nsites > 2 but don't look quite right for nsites=3.
from rms.
Related Issues (20)
- Issue installing on R version 4.0.0 HOT 2
- Fatal error in Gls(B > 0)
- allow to pass argument to solver (SparseM)
- Anova command does not run with lapply
- How to include time-vary covariates using tt=function from coxph in rcs code?
- print.Gls() using corSymm() returns error message.
- lrm and Rcmdr conflict HOT 2
- rexVar in survival model (cph) HOT 1
- How to estimate OR and 95%CI using Predict funtion for svyglm model?
- RCS curve in competing risk model
- Estimating contrasts and marginal effects from aregImpute multiply imputed data
- Accidentally turning on backward step-down procedure in `validate` and `calibrate`
- Compare absolute effects with Contrast function HOT 1
- Error with nomogram: Error in reformulate(attr(termobj, "term.labels")[-dropx], response = if (keep.response) termobj[[2L]], : 'termlabels' must be a character vector of length at least one HOT 1
- "nomogram" function dosn't work HOT 3
- Trouble with definition of "D" in `val.prob`.
- Blank screen - survplot HOT 1
- Warning when using summary() for a logistic regression model for long model formulas HOT 1
- survplot - set your own axis
- lrtest() accepts models fit on different number of observations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rms.