library(mice)
md.pattern(dat1)
temp<-mice(dat1, m = 5, seed = 101)
dat1 <- complete(temp, 2)
Error in UseMethod("complete_") :
no applicable method for 'complete_' applied to an object of class "mids"
Hi, I'm trying to impute missing values using mice package.
But I got the above error message.
The first time I imputed missing data it worked, but when I tried again it didn't. I've tried a lot with different options (changing seed, deleting existing data or "temp" variable)
Sometimes it worked but other times it didn't.
What is the problem and solution?
Thanks in advance.
I think the problem here is that you should rather be using some other libraries in your program which have a function named "complete". Just typing "complete" in help menu gave me 2 other libraries (tidyr,RCurl) which have the function in the same name. As simon suggested, I tried using "mice::complete". It works for me.
Try this:
dat1<-mice::complete(temp,2)
mice 3.7.5 redefines the complete() function as the S3 complete.mids() method for the generic tidyr::complete().
Assuming that mice is attached, you should no longer see no applicable method for 'complete_' applied to an object of class "mids".
Related
I am having trouble getting the pairs() function to work in nlme. Take this example from Pinhiero and Bates Mixed-Effects Models in S and S-Plus.
The model itself runs just fine
fm1Theo.lis <- nlsList(conc ~ SSfol(Dose, Time, lKe, lKa, lCl), data = Theoph)
But the pairs plot...
pairs(fm1Theo.lis, id = 0.1)
...returns this error
Error in as.data.frame.default(x) :
cannot coerce class "c("nlsList", "lmList")" to a data.frame
I also tried
pairs(fm1Theo.lis, ~ ranef(., level = 2), id = 0.1)
But get the same error. Any ideas?
Here's how one may think in this case. The error
Error in as.data.frame.default(x) :
cannot coerce class ‘c("nlsList", "lmList")’ to a data.frame
says that some object of class c("nlsList", "lmList") is being coerced to a data frame. Now since fm1Theo.lis is the result of using nlsList, it seems that the object in the error is indeed nlsList. That means that pairs does not know what to do with objects of such class. To confirm this, we can run
pairs.default(fm1Theo.lis, id = 0.1)
which is what is going to happen when no specific method for fm1Theo.lis is found. Indeed the error is the same. In one way or another confirming that nlsList and comes from nlme, it becomes clear that the issue is with loading the nlme package. Loading it or restarting the session then is almost surely going to help.
Need some assistance in R. I ran the lm function and assigned it to variable. Then I used that variable to retrieve summary using pool() function.
Here's the code but getting argument data is missing. I saw same example but didn't get that error.
> modelFit1 <- with(imputed,lm(MPG ~ CYLINDERS+SIZE+HP+WEIGHT+ACCEL+ENG_TYPE))
> summary(pool(modelFit1))
Error in pool(modelFit1) : argument "data" is missing, with no default
Appreciate any help. Thanks.
I also had this error. In my case it was due to conflicting packages. I had loaded packages: "mice" and "mi", and "mitools", among others. There is no 'data' argument necessary for 'pool' in the "mice" package, but mi::pool does require a data argument. If you are using mice and following examples in mice's documentation, Try
pooled <- mice::pool(modelFit1))
summary(pooled)
I am trying to remove the duplicates of a master dataset with respect to a column, using "assign" does not work, the piece of the code is the following
varlist <- unique(Master_Data$Composite)
for (var in varlist){
assign(paste("Data_",var,sep=""),filter(paste("Data_",var,sep=""), !is.na(paste("Data_",var,sep=""))$Composite.T.))
}
The error I am getting is:
Error in UseMethod("filter_") :
no applicable method for 'filter_' applied to an object of class "character"
This is done relatively easy in SAS Macro, but I am sure R has features of it. Perhaps this has already been answered, I searched but couldn't find working solutions.
Thanks alot in advance,
M.
I am trying to use bestglm on a logistic regression model fitting a smaller sample of my data (100x25) matrix (originaly 250kx40).
I run it in BATCH mode. and I wish to write the bestglm models to a file.
dput(test2,file="test2.txt",control=c("keepNA","keepInteger","showAttributes"))
t2<-dget(file="test2.txt")
Error in UseMethod("family") :
no applicable method for 'family' applied to an object of class "NULL"
Any ideas as to how to solve this problem?
There is something in the dput'ing of the bestglm that isn't right. If you simply dput to the console, copy+paste it back in to a new object, it will fail with the same error.
It may be a bug and you may want to reach out to the package maintainer(s).
In the meantime, try using saveRDS and readRDS:
saveRDS(test2, file="test2.rds")
t2 <- readRDS("test2.rds")
I have updated to the last version of R and updated the rugarch package as well.
Unfortunately some code that worked previously no longer works. I now get an error.
I would be greatful for some help to get the output into a dataframe.
library(rugarch)
data(sp500ret)
spec = ugarchspec( )
fit1 = ugarchfit(spec = spec, data = sp500ret)
df.fit1 <- as.data.frame(fit1,which="VaR")
Error in as.data.frame.default(fit1, which = "VaR"):
cannot coerce class "structure("uGARCHfit", package = "rugarch")" to a
data.frame
attributes(fit1)
shows:$fit$sigma
but when I try:
df1 <- data.frame(fit1$fit$sigma)
I get an error message;
Error in fit1$fit : $ operator not defined for this S4 class
as.data.frame(fit1, which="VaR") NEVER worked with an object of class uGARCHfit (you are confusing this with a uGARCHroll object). If you want the conditional VaR you can NOW (in the new version) use the quantile method e.g. quantile(fit1, c(0.01,0.05)).
If you want the conditional standard deviation then you should use sigma(fit1) which will return an xts matrix, or fit1#fit$sigma (# goes after an object in S4 classes). This and most other questions can be answered by carefully reading the documentation, vignette and the author's website which contains details of the changes.