You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do not understand the behaviour of the function predict.yai when I apply it to new data. It returns NAs for the observed values. Why is this happening?
I made a reroducible example based on the MoscowMtJoe data.
library(yaImpute)
data("MoscowMtStJoe")
x <- MoscowMtStJoe[, c("EASTING", "NORTHING", "ELEVMEAN",
"SLPMEAN", "ASPMEAN", "INTMEAN", "HTMEAN", "CCMEAN")]
x[, 5] <- (1 - cos((x[, 5] - 30) * pi/180))/2
names(x)[5] = "TrASP"
y <- MoscowMtStJoe[, c(1, 9, 12, 14, 18)]
# Create yai object
mal <- yai(x = x, y = y, method = "mahalanobis")
# Create a new dataset with 30 observations based on original data but adding a bit of variance
random = sample(rownames(x), nrow(x))
nd.y = y[random,] +runif(nrow(x), min = 0.1, max = 0.5)
nd.x = x[random,] +runif(nrow(x), min = 0.1, max = 0.5)
nd = cbind(nd.y, nd.x)[1:30,]
rownames(nd) = paste0("n",1:nrow(nd))
# predict
p = predict.yai(object = mal, newdata = nd, observed = T)
head(p) # predicted
> ABGR_BA PIPO_BA PSME_BA THPL_BA Total_BA ABGR_BA.o PIPO_BA.o PSME_BA.o THPL_BA.o Total_BA.o
> n1 12.938903 0 1.201908 31.5207887 59.9378177 NA NA NA NA NA
> n2 2.447804 0 11.993483 30.8633313 56.4527989 NA NA NA NA NA
> n3 0.000000 0 0.000000 0.3806958 1.4782311 NA NA NA NA NA
> n4 0.000000 0 0.000000 0.0000000 0.3383963 NA NA NA NA NA
> n5 0.000000 0 6.746213 0.0000000 7.1332287 NA NA NA NA NA
> n6 10.357833 0 0.000000 244.8680129 255.4436635 NA NA NA NA NA
head(nd[,1:5]) # observed
> ABGR_BA PIPO_BA PSME_BA THPL_BA Total_BA
> n1 13.2327991 0.2938965 1.4958040 31.8146852 60.2317142
> n2 2.6028360 0.1550319 12.1485148 31.0183632 56.6078308
> n3 0.2097972 0.2097972 0.2097972 0.5904930 1.6880283
> n4 0.1568212 0.1568212 0.1568212 0.1568212 0.4952175
> n5 0.4952800 0.4952800 7.2414930 0.4952800 7.6285087
> n6 10.6680486 0.3102155 0.3102155 245.1782284 255.7538790
The text was updated successfully, but these errors were encountered:
I do not understand the behaviour of the function
predict.yai
when I apply it to new data. It returns NAs for the observed values. Why is this happening?I made a reroducible example based on the MoscowMtJoe data.
The text was updated successfully, but these errors were encountered: