TrainAttempt$PriceGuess <- with(TrainAttempt,
0+(LotFrontage*1)+(LotArea*1)+
(MasVnrArea*1)+(BsmtFinSF1*1)+
(BsmtFinSF2*1)+
(BsmtUnfSF*1)+
(TotalBsmtSF*1)+
(GrLivArea*1) +
(BsmtFullBath*1) +
(BsmtHalfBath*1) +
(FullBath*1) +
(HalfBath+0) +
(BedroomAbvGr*1) +
(KitchenAbvGr*1) +
(TotRmsAbvGrd*1) +
(Fireplaces*1) +
(OpenPorchSF*1) +
(GarageArea*1) +
(WoodDeckSF*1) +
(OpenPorchSF+0) +
(EnclosedPorch*1) +
(ScreenPorch*1) +
(PoolArea*1) +
(MiscVal*1))
I am running the following code:
mydata1 = data.frame(dataset)
mydata1 <- na.omit(mydata1)
bw <- npplregbw(mydata1$X1 ~ mydata1$X2 + mydata1$X3 + mydata1$X4 + mydata1$effect_1993 + mydata1$effect_1994 + mydata1$effect_1995 + mydata1$effect_1996 + mydata1$effect_1997 + mydata1$country_2 + mydata1$country_3 + mydata1$country_4 + mydata1$country_5 + mydata1$country_6 + mydata1$effect_1998 + mydata1$effect_1999 + mydata1$effect_2000 + mydata1$effect_2001 + mydata1$effect_2002 + mydata1$effect_2003 + mydata1$effect_2004 + mydata1$effect_2005 + mydata1$effect_2006 + mydata1$effect_2007 + mydata1$effect_2008 + mydata1$effect_2009 + mydata1$effect_2010 + mydata1$effect_2011 + mydata1$effect_2012 + mydata1$effect_2013 + mydata1$effect_2014 + mydata1$effect_2015 + mydata1$effect_2016 + mydata1$effect_2017 + mydata1$effect_2018 + mydata1$effect_2019 + mydata1$effect_2020 + mydata1$effect_2021|mydata1$X5 + mydata1$X6 + mydata1$X7 + mydata1$X8, data = mydata1, na.action = na.omit)
summary(bw)
reg_np <- npplreg(bw)
The code is running fine except the last command which gives the following error:
Error in chol.default(t(model.matrix(model)) %*% model.matrix(model)) :
the leading minor of order 4 is not positive definite
My data do not have 0 (except the fixed effects data) or NA values.
Is there any way I can proceed with the npplreg regression without getting that error?
Thanks a lot in advance
How can i find out how many observations were used in a regression?
model_simple <- as.formula("completion_yesno ~ ac + ov + UCRate + FirstWeek + LastWeek + DayofWeekSu + DayofWeekMo + DayofWeekTu + DayofWeekWe + DayofWeekTh + DayofWeekFr + MonthofYearJan + MonthofYearFeb + MonthofYearMar + MonthofYearApr +MonthofYearMay+ MonthofYearJun + MonthofYearJul + MonthofYearAug + MonthofYearSep + MonthofYearOct + MonthofYearNov")
clog_simple1 = glm(model_simple,data=cllw,family = binomial(link = cloglog))
summary(clog_simple1)
I have tried the fitted command which did not result in a concrete number of observations N
Use the built in nobs() function
nobs(clog_simple1)
I would like to fit a regression by trying different polynomials, and I tried running this loop:
for (p_order in 1:9) {
assign(paste("RD0", p_order, sep = ""), electricity_price ~ d1 + gas_price + coal_price +
oil_price + EUA + weekday + month + median_windspeed1 +
median_windspeed2 + median_windspeed3 + median_windspeed4 +
sun1 + sun2 + sun3 + sun4 + median_temp1 + median_temp2 +
median_temp3 + median_temp4 + poly(as.numeric(date), p_order, raw=TRUE) + time)
}
Although it creates correctly the names of the variables (RD01, RD02, etc), instead of saving the correct order of the polynomial (1,2, etc) it stores "p_order". For example,
> RD04
electricity_price ~ d1 + gas_price + coal_price + oil_price +
EUA + weekday + month + median_windspeed1 + median_windspeed2 +
median_windspeed3 + median_windspeed4 + sun1 + sun2 + sun3 +
sun4 + median_temp1 + median_temp2 + median_temp3 + median_temp4 +
poly(as.numeric(date), p_order, raw = TRUE) + time
> RD07
electricity_price ~ d1 + gas_price + coal_price + oil_price +
EUA + weekday + month + median_windspeed1 + median_windspeed2 +
median_windspeed3 + median_windspeed4 + sun1 + sun2 + sun3 +
sun4 + median_temp1 + median_temp2 + median_temp3 + median_temp4 +
poly(as.numeric(date), p_order, raw = TRUE) + time
Could someone explain me why and how to sort this out?
Thank you!
Create the formula first, then assign it. I will post a simplified example.
for (p_order in 1:2) {
fmla <- paste("electricity_price ~ d1 + poly(as.numeric(date),", p_order, ", raw = TRUE)")
assign(paste("RD0", p_order, sep = ""), as.formula(fmla))
}
RD01
#electricity_price ~ d1 + poly(as.numeric(date), 1, raw = TRUE)
RD02
#electricity_price ~ d1 + poly(as.numeric(date), 2, raw = TRUE)
I have this model and I need to calculate "AIC" to make model selection, my problem is that when I run the model "AIC" appears as "NA".
MODEL= svyglm(formula = Asiste ~ afro + sexo + E27 + JovenActivo + hijos +
jefe + LN_YSVL_sin_joven_prom + aniosed + climaeducativo +
Mdeo + icv2 + TV + Computadora + Telefono + Internet + Cable +
Calefon + DVD + Microhondas + Aire + Auto_o_moto + Secadora +
Madre_ausente + Internet + TV + Lavavajillas + Refrigerador +
climaeducativo + Actividad_del_Jefe + Hacinamiento, family = quasibinomial(link =
"logit"),
data = Personas.con.muestra, design = diseƱo_personas_14_17,
subset = (Stratum != 0))
MODEL$aic
[1] NA
Any suggestion?
Thanks!! Natalia
You can try this:
summary(MODEL)$aic