GAM "missing value where TRUE/FALSE needed" - gam

I'm getting this error when I try to run a mgcv::bam model with discrete = TRUE and random effects s(x1, bs = "re") in the smooths.
Error in if (nt[2] > 1) pchol(t(XXp/d)/d, nt[2]) else suppressWarnings(chol(t(XXp/d)/d, : missing value where TRUE/FALSE needed
Any ideas what the cause is?

Related

np.isnan() function not solving "divide by zero encountered in true_divide" warning

Pdict = {"KobeBryant":0,"JoeJohnson":1,"LeBronJames":2,"CarmeloAnthony":3,"DwightHoward":4,"ChrisBosh":5,"ChrisPaul":6,"KevinDurant":7,"DerrickRose":8,"DwayneWade":9}
Salary = np.array([KobeBryant_Salary, JoeJohnson_Salary, LeBronJames_Salary, CarmeloAnthony_Salary, DwightHoward_Salary, ChrisBosh_Salary, ChrisPaul_Salary, KevinDurant_Salary, DerrickRose_Salary, DwayneWade_Salary])
Games = np.array([KobeBryant_G, JoeJohnson_G, LeBronJames_G, CarmeloAnthony_G, DwightHoward_G, ChrisBosh_G, ChrisPaul_G, KevinDurant_G, DerrickRose_G, DwayneWade_G])
plr =[]
for v in Pdict.values():
for s in Salary:
for g in Games:
if np.isnan(g[v]) == True: continue
z = np.round(np.divide(s[v], Games[v]), 2)
plr.append(z)
print(plr)
print(type(z))
Im trying to make a new matrix called plr, there is a zero in Games[] and Im trying to make it skip it instead of giving me that error. I found the np.isnan() but it seems to do nothing here. If I run the code with or without that line, it still gives me the runtime warning. Im not sure what Im doing wrong with it or is there a better way to do this?

Compile Error: Function Call on Left-hand side of assignment

I got the compile error
"Function call on left-hand side of assignment must return Variant or Object"
Trying to fix an inherited Excel file that calculates various values related to HVAC. The file relies on a couple of Add-In .xla files which contain many functions. I am unable to get results from most of the functions. Either I get numbers that immediately turn to zeros, or I just get #VALUE and #NAME errors.
My VBA skills are somewhat limited as well as my knowledge of the calculations this file is performing.
Function EvapDeltaGrn(altitude, evap_on, tdb_ma, hr_ma, sat_goal, hr_min)
'use to calculate the delta grain when tdb_oa > than sat_goal
EvapDeltaGrn = 0
If tdb_ma = "" Then Exit Function
If hr_ma = "" Then Exit Function
If evap_on Then
If tdb_ma >= (sat_goal) Then 'use evaporative cooling
Enthalpy = Application.Run("'psychrometric functions.xla'!TdbGrainstoEnthalpy", altitude, tdb_ma, hr_ma)
'Range("v14") = enthalpy
EvapDeltaGrn = Application.Run("'psychrometric functions.xla'!TdbEnthalpytoGrains", altitude, sat_goal, Enthalpy)
EvapDeltaGrn = EvapDeltaGrn - hr_ma
EvapDeltaGrn = Round(EvapDeltaGrn, 2)
Else 'evaporative humidification
If hr_ma < hr_min Then EvapDeltaGrn = Round(hr_min - hr_ma, 2)
End If
End If
End Function
The error seems to be at Enthalpy =.

using as.ppp on data frame to create marked process

I am using a data frame to create a marked point process using as.ppp function. I get an error Error: is.numeric(x) is not TRUE. The data I am using is as follows:
dput(head(pointDataUTM[,1:2]))
structure(list(POINT_X = c(439845.0069, 450018.3603, 451873.2925,
446836.5498, 445040.8974, 442060.0477), POINT_Y = c(4624464.56,
4629024.646, 4624579.758, 4636291.222, 4614853.993, 4651264.579
)), .Names = c("POINT_X", "POINT_Y"), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))
I can see that the first two columns are numeric, so I do not know why it is a problem.
> str(pointDataUTM)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 5028 obs. of 31 variables:
$ POINT_X : num 439845 450018 451873 446837 445041 ...
$ POINT_Y : num 4624465 4629025 4624580 4636291 4614854 ...
Then I also checked for NA, which shows no NA
> sum(is.na(pointDataUTM$POINT_X))
[1] 0
> sum(is.na(pointDataUTM$POINT_Y))
[1] 0
When I tried even only the first two columns of the data.frame, the error I get on using as.ppp is this:
Error: is.numeric(x) is not TRUE
5.stop(sprintf(ngettext(length(r), "%s is not TRUE", "%s are not all TRUE"), ch), call. = FALSE, domain = NA)
4.stopifnot(is.numeric(x))
3.ppp(X[, 1], X[, 2], window = win, marks = marx, check = check)
2.as.ppp.data.frame(pointDataUTM[, 1:2], W = studyWindow)
1.as.ppp(pointDataUTM[, 1:2], W = studyWindow)
Could someone tell me what is the mistake here and why I get the not numeric error?
Thank you.
The critical check is whether PointDataUTM[,1] is numeric, rather than PointDataUTM$POINT_X.
Since PointDataUTM is a tbl object, and tbl is a function from the dplyr package, what is probably happening is that the subset operator for the tbl class is returning a data frame, and not a numeric vector, when a single column is extracted. Whereas the $ operator returns a numeric vector.
I suggest you convert your data to data.frame using as.data.frame() before calling as.ppp.
In the next version of spatstat we will make our code more robust against this kind of problem.
I'm on the phone, so can't check but I think it is happens because you have a tibble and not a data.frame. Please try to convert to a data.frame using as.data.frame first.

Quinlan Attribute C5.0

Error in UseMethod("QuinlanAttributes") :
no applicable method for 'QuinlanAttributes' applied to an object of class "logical"
I am getting this error whenever I am running a code. I have installed several packages but this error is keep on repitiating.
it seems that C50 does not accept BOOLEAN features.
you can simpliy drop that column or replace BOOLEAN to 0/1.
if "tdata$Windy" is the BOOLEAN feature, replace the value of it.
library(C50)
tdata = read.csv('play.csv', header = TRUE, sep = ",")
xdata <- data.frame(tdata$Outlook,tdata$Temperature, tdata$Humidity, tdata$Windy)
ydata <- tdata$Play
treeModel <- C5.0(x = xdata, y = ydata )
summary(treeModel)
It's old question but I had same issue today and realized it's was due to read_sav().
I solved applying haven::as_factor to columns that should be factors.
data <- read_sav("datafile.sav")
data <- mutate(data, across(ends_with("_fct"), haven::as_factor ))

How to get rid of lmer warning message?

I have made some changes to the lmer. It works as it should but I could not get rid of the warning message that pops when I run the program. I have added the following options which allows the program run without stopping but with the warning message. I believe it is the check.nobs.vs.rankZ = "warningSmall" part. How could I get rid of this, any suggestions? Thank you.
lmerControl(check.nobs.vs.nlev = "ignore",check.nobs.vs.rankZ =
"warningSmall",check.nlev.gtreq.5 = "ignore",check.nobs.vs.nRE="ignore",
check.rankX = c("ignore"),check.scaleX = "ignore",check.formula.LHS="ignore",
## convergence checking options
check.conv.grad = .makeCC("warning", tol = 1e-3, relTol = NULL),
check.conv.singular = .makeCC(action = "ignore", tol = 1e-4),
check.conv.hess = .makeCC(action = "warning", tol = 1e-6)
Warning Message from R:
Warning message:
In checkZrank(reTrms$Zt, n = n, control, nonSmall = 1e+06) :
number of observations (=300) <= rank(Z) (=300); the random-effects parameters and the
residual variance (or scale parameter) are probably unidentifiable
You should try check.nobs.vs.rankZ="ignore".
lmerControl doesn't need to specify anything other than the non-default options: at a quick glance, these are your non-default values:
lmerControl(check.nobs.vs.nlev = "ignore",check.nobs.vs.rankZ =
"ignore",check.nlev.gtreq.5 = "ignore",check.nobs.vs.nRE="ignore",
check.rankX = c("ignore"),
check.scaleX = "ignore",
check.formula.LHS="ignore",
check.conv.grad = .makeCC("warning", tol = 1e-3, relTol = NULL))
In general I would suggest it's wise to turn off only the specific warnings and errors you know you want to override -- the settings above look like they could get you in trouble.
I haven't checked this since you didn't give a reproducible example ...

Resources