R rms package error when using rcs() - r

Been looking into Harrell's rms package for R and I am getting an error whenever I try to use the spline function rcs() inside a formula. This happens with all datasets. Is there some R setting I am missing?
library(rms)
df = read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
m = lrm(admit~ rcs(gre), df)
Error in rcspline.eval(x, nk = nknots, inclx = TRUE, pc = pc, fractied = fractied) :
unused argument (fractied = fractied)
What is "fractied"? I haven't been able to find a clear explanation.
I'm using Windows 7, R version 3.1.0, rms version 4.2.0

Related

renewalCount() function in countr package in R

I am trying to use renewalCount() function in R to get the fitted model of Weibull Distribution. Here is my piece of code:
wei <- renewalCount(formula = packets ~ 1,
data = dfdata,
dist = "weibull", weiMethod = "series_acc",
computeHessian = FALSE,
control = renewal.control(trace = 0))
I am facing the following exception while running this:
error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD
Error in optimx.check(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, :
Cannot evaluate function at initial parameters
I am a newbie in the field of R programming and have tried solutions like importing optimx and RcppArmadillo library but it did not work. Is there a way to enable ARMA_64BIT_WORD in RStudio. Any help would be really appreciated. Thanks in advance!

How to run zero inflated poisson in R if zeroinfl function cannot be found?

I am using R version 3.6.0 and I am following this guide in order to run a zero-inflated poisson regression on cholera data: https://stats.idre.ucla.edu/r/dae/zip/
I have installed the pscl package as instructed, but when I run my code, an error message shows.
cholera2 <- within(cholera, {wateraccess <- factor(wateraccess, order=TRUE, levels=c(1,2,3,4))})
summary(cholera2)
summary(m1 <- zeroinfl(cases ~ wateraccess + atpc, data = cholera2))
I tried using a different version of R and it has the same issue.
Error message: Error in zeroinfl(cases ~ wateraccess + atpc, data = cholera2) : could not find function "zeroinfl"

Stargazer error with polr in R

I obtain an error when using stargazer in conjunction with polr from the MASS package in R. Here is an example:
library(MASS)
library(stargazer)
# Fake data
set.seed(1234)
fake_data <- data.frame(y = as.factor(sample.int(4, 20, replace = TRUE)),
x1 = rnorm(20, mean = 1, sd = 1),
x2 = rnorm(20, mean = -1, sd = 1))
# Ordered logistic regression
o_log <- MASS::polr(y ~ x1 + x2,
data = fake_data,
Hess = TRUE, method = "logistic")
summary(o_log)
# Create regression table
stargazer(o_log)
I receive the following error message:
% Error: Unrecognized object type.
Does anyone know how to solve this? Thanks in advance.
P.S.: I'm on OS X 10.13, using R 3.4.3, MASS 7.3.47, and stargazer 5.2.
EDIT: According to stargazer's vignette, objects from polr should be supported.
I don't know the reason but when I change MASS::polr into plor, the error is removed and it works fine. It seems that it is a bug of package stargazer.
I encountered the same problem. For some strange reason, this only happens when you call the function using :: (in your case: MASS::polr). It doesn't happen when you first load the package via library(MASS) and then call the specific function.
See: Why do I get different results when using library(MASS) vs. MASS::?
I guess it was because you didn't load the MASS library and instead called the function using ::. MASS library doing some updates on how summary works for polr, which is being used by stargazer to generate the table. By not loading the library, the update was not happened, hence bringing you some trouble with stargazer.

Running GAM function from mgcv package with R 3.2.2

I have recently run into a problem running a GAM model from a previously working code. I believe it is related to an updated R-Version and an updated Version of the mgcv package. It would be great to know if anyone has the same problem or has a solution to it.
I am currently running R version 3.2.2 (2015-08-14) -- "Fire Safety"
on Windows. I am using the mgcv Package 1.8-7. Below is an example code that re-produces the error message, when run on my computer.
###Load package
library(mgcv)
This is mgcv 1.8-7.
###Simulate some example data
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
###Run normal model
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat, family=gaussian())
This works.
###change the smoothness selection method to REML
b0 <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat,method="REML")
Gives the following error message:
Error in .C(C_gdi1, X = as.double(x[good, ]), E = as.double(Sr), Eb = as.double(Eb), : Incorrect number of arguments (48), expecting 47 for 'gdi1'
Thanks for your help!
I have re-installed R and the mgcv package and it seems as if this has resolved the issue.

rpart package issue in R 3.0.1 version

i am newbie to R
i am using R 3.0.1 version,
I have installed rpart package using
install.packages("rpart")
selected USA(CA 1) in the pop up box and it is installed successfully
> p_data = read.csv(file="/home/sudeep/Desktop/mysql.tsv",sep="\t",dec=".",header=TRUE)
> dtree <- rpart(paid ~ .,data = p_data, method="class")
Error: could not find function "rpart"
so what is wrong with me??
You don't actually need to install rpart manually; it comes with the base R distribution. However, you do need to load it into your R session with a call to library:
library(rpart)
rpart(paid ~ ., data=....)

Resources