Sort.score in R - r

I am unable to run the code for sort.score in R,
I get the following error:Error in sort.score(AIC(m000.avalon, m001.avalon, m101.avalon, m200.avalon) :
could not find function "sort.score".
can anyone advice, where I am going wrong . Thank you

The function is actually sortScore, not sort.score. Try this instead, it will work for sure.

Related

attempt to apply non-function(R)

I'm trying to run the following code in R, but I'm getting an error.
I'm not sure what part of the formula is incorrect. Any help would be greatly appreciated.
loglik<-function(y,theta)
{
mu=theta[1]
sigma2=theta[2]
lambda=theta[3]
n=length(y)
-0.5*n*log(2*pi)-0.5*n*log(sigma2)-sum((y^lambda-1)/lambda-mu)^2/(2*sigma2)+(lambda-1)(sum(log(y)))
}
Error: attempt to apply non-function
The issue is in
(lambda-1)(sum(log(y))
If it needs to be multiplied, add the *
(lambda-1)*(sum(log(y))
You are missing a * in the final line of the function.. Should be
(lambda-1)*(sum(log(y)))

is there a way to make the for loop run a command like this?

i have some datasets named f1998-f2005 and i wanna use looping to run the following commands because it is a hassle to type line after lines of commands, i tried running the following codes to make it more automated:
for (i in 1998:2005) {
model.poissqmle.f1.199(i) <- glm(formula1, data=f199(i), family=quasipoisson()
print (summary(model.poissqmle.f1.199(i)))
}
but r returned me the following message:
Error: unexpected '}' in:
" + print (summary(model.poissqmle.f1.199(i)))
}"
Thanks for your help, my foundations in R is really weak but i have to use it for one of my research now hence i would really appreciate a kind soul to help me out. Thanks!

Invalid formula error in R - xtabs function giving environment issure

When trying to run this (or any other) command
xtabs(ugdata$response, ugdata$Equity, data=ugdata)
I keep receiving this error
Error in formula.default(object, env = baseenv()) : invalid formula
I have been looking around all day, including similar posts on this website, but I cannot find a solution to help me fix this.
Any help would be greatly appreciated
I believe the error is in the syntax. Please try:
xtabs(ugdata$response ~ ugdata$Equity, data = ugdata)

what happened to missing.pattern.plot or mp.plot?

I have the package mi installed.
But when I try to run mp.plot (as Thomas Leeper does in this tutorial:) I get the following error message:
mp.plot(mydf)
Error in mp.plot(mydf) : could not find function "mp.plot"
On one website this is called missing.pattern.plot, but that also does not work:
missing.pattern.plot(mydf)
Error in missing.pattern.plot(mydf) :
could not find function "missing.pattern.plot"
Any idea what the issue might be?
I do not really care much if I cannot use this function, but I'm curious as to what is going on in case I later need to use a graph that I really need.

Function not working anymore when executed from own package

Hope you can give me a quick help:
I have a function that works perfect as run in the global envir. When I eval the function from my own package it gives me an error. I can't figure out what the problem is. Seem so random to me.
catTableFun(aaa,grouped_by = "varNameAsString",preview=T) #from global envir works as expected
elricoFuns::catTableFun(aaa,grouped_by = "varNameAsString",preview=T) # identical function run from package gives the following error
Error:
#Error in get(grouped_by) : object 'varNameAsString' not found
Its such a construct causing the error. But why?
setDT(x)
gnLevels <- x[,get(grouped_by),drop=F]
I'm sorry I cant give you some rep example and this is a broad question, but I hope someone has encountered a similar phenomenon or has an educated guess about it.

Resources