I am using svyglm model, I need to get "AIC" to compare differents models.
My problem is that if I use my model:
Modelo12=svyglm(formula = Asiste ~ sexo + E27 + JovenActivo + hijos +
+ jefe + LN_YSVL_sin_joven_prom + aniosed + climaeducativo +
+ icv2 + TV + Computadora + Telefono + Cable + Calefon +
+ DVD + Microhondas + Aire + Auto_o_moto + Secadora + Lavavajillas +
+ Refrigerador + Actividad_del_Jefe + Hacinamiento, family = quasibinomial(link
=
"probit"), data = Personas.con.muestra, design=diseno_personas_14_17)
when I write summary(Modelo12) AIC doesnt appears.
In other hand, I can`t use stepwise, this is the error:
stepwise(Modelo12)
Direction: backward/forward forward/backward backward forward
Criterion: BIC
Error en extractAIC.svyglm(fit, scale, k = k, ...) :
svyglm not fitted by maximum likelihood
THANKS!!!
Natalia
AIC is a likelihood based measure. svyglm does not use maximum likelihood fitting, as the error and ?svyglm tell you. There you also get the advice to use regTermTest, which provide Wald tests and adjusted Rao-Scott likelihood ratio test.
Related
I am running a regression analysis of the housing market, where I test how the independent variables are affecting the dependent variable (Price).
I am running the following code for the OLS:
reg.model1 <- log(Price2) ~ Detached.house + Semi.detached.house + Attached.houses - Apartment +
Stock.apartment + Housing.cooperative - Sole.owner + Age +
BRA + Bedrooms + Balcony + Lotsize + Sentrum + Alna + Vestre.Aker + Nordstrand + Marka +
Ullern + Østensjø + Søndre.Nordstrand + Stovner + Nordre.Aker + Bjerke +
Grorud + Gamle.Oslo + St..Hanshaugen + Grünerløkka + Sagene - Frogner
reg1 <- lm(formula = reg.model1, data = Data)
The next step was to test for Heteroscedasticity by running Breusch-Pagan Test:
bptest(reg1)
I got the following results in the consol:
As far as I understand, since the P-value is smaller than 0.05 this means Heteroscedasticity is present.
So what I struggle with is what to do next to correct for Heteroscedasticity, I have read that there are several ways to correct this. However, everything I have tried has failed, most likely because I have done something wrong. If someone could guide me on how to correct this I would really appreciate it!
The model I am trying to implement using laplace approximation i s below:
model2<-lmer(ChickWeight$weight~Time + Diet + Time*Diet + (1+Time|Chick), data = ChickWeight)
summary(model2)
I was trying to use the code below to do this but i am not sure:
#Laplace approximation
library(glmmsr)
mod_Laplace <- glmm(ChickWeight$weight~Time + Diet + Time*Diet + (1+Time|Chick), data = ChickWeight,
family = gaussian, method = "Laplace")
I am getting an error as the output
I would like to calculate marginal effects for this logistic model with clustered standard errors which I computed with miceadds::glm.cluster.
fullmodel3 <- miceadds::glm.cluster(data = SDdataset17,
formula = stigmatisation_dummy_num ~ gender + age +
agesquared + education_new + publicsector +
retired + socialisation_sd + selfplacement_num +
years_membership + voteshare,
cluster = "voteshare", family = "binomial")
Given that I am not using glm(), most functions I have seen around do not work.
Any suggestions?
I know, that when I'm using lm() or glm() function to fit the regression model in R, it's possible to write interactions up to n-th degree like this:
fit <- glm(formula=outVar ~ (inVar1 + inVar2 + inVar3)^n,
data=d)
But is it possible to do similar thing with the power of variables, so I don't have to specify I(inVar1^2), I(inVar1^3) and to exclude interactions between different powers of the same variable?
EDIT
I'd like to do something like this:
formula=outVar ~ (poly(inVar1 + inVar2 + inVar3, 2))^2
So I'd get the formula
outVar ~ inVar1 + inVar2 + inVar3 + I(inVar1^2) + I(inVar2^2) + I(inVar3^2) + inVar1:inVar2 + inVar1:inVar3 + inVar2:inVar3 + I(inVar1^2):I(inVar2^2) + I(inVar1^2):I(inVar3^2) + I(inVar1^2):I(inVar3^2) + inVar1:I(inVar2^2) + inVar1:I(inVar3^2)...
Is there anyone can help me implement a ROC curve for a bayesian logistic regression? been trying DPpackage but is it me or it just doesn't work.
the two models i want to compare using ROC Curve are showed below:
bayes_mod=MCMClogit(Default ~ ACTIVITY + CIF + MAN + STA + PIA + COL + CurrLiq + DebtCov + GDPgr, data=mydata, burnin=500000,mcmc=10000, tune=0.6,b0=coef(mylogit.reduced),B0=information2, subset=c(-1772,-2064,-655))
bayes_mod1=MCMClogit(Default ~ ACTIVITY + CIF + MAN + STA + PIA + COL + CurrLiq + DebtCov + GDPgr, data=mydata, burnin=500000,mcmc=10000,tune=0.6,subset=c(-1772,-2064,-655))
where Default ~ ACTIVITY + CIF + MAN + STA + PIA + COL + CurrLiq + DebtCov + GDPgr are my arguments; mydata is the database; mylogit.reduced is a logistic regression estimated prior to bayesian, B0 is the covariation matrix, and subset=c are the eliminated observations.
I don't know this package, but it probably provides a predict function (actually it does, I just can't find if it does for MCMClogit models as I can't find the doc for this function). You can then pass it to a ROC function like pROC:
library(pROC)
predictions <- predict(mydata, newdata=mytestdata)
roc(mytestdata$Default, predictions)