Displaying 20 results from an estimated 10000 matches similar to: "calculating likelihood-based CI"
2003 Apr 17
4
A function as argument of another function
Dear all,
I would like to write a function like:
myfun<-function(x,fn) {xx<-exp(x); x*fn(xx)}
where fn is a symbolic description of any function with its argument to be
specified. Therefore
myfun(5,"2+0.3*y^2")
should return 5*(2+0.3*exp(5)^2),
myfun(5,"log(y)") should return 5*log(exp(5)) and so on.
I tried with "expression" and others, but without success.
2008 Jun 30
2
difference between MASS::polr() and Design::lrm()
Dear all,
It appears that MASS::polr() and Design::lrm() return the same point
estimates but different st.errs when fitting proportional odds models,
grade<-c(4,4,2,4,3,2,3,1,3,3,2,2,3,3,2,4,2,4,5,2,1,4,1,2,5,3,4,2,2,1)
score<-c(525,533,545,582,581,576,572,609,559,543,576,525,574,582,574,471,595,
557,557,584,599,517,649,584,463,591,488,563,553,549)
library(MASS)
library(Design)
2003 Dec 16
3
`bivariate apply'
dear all,
Given a matrix A, say, I would like to apply a bivariate function to each
combination of its colums. That is if
myfun<-function(x,y)cor(x,y) #computes simple correlation of two vectors x
and y
then the results should be something similar to cor(A).
I tried with mapply, outer,...but without success
Can anybody help me?
many thanks in advance,
vito
2012 Apr 02
7
Calculating NOEL using R and logistic regression - Toxicology
Hello, I used the glm function in R to fit a dose-response relationship and
then have been using dose.p to calculate the LC50, however I would like to
calculate the NOEL (no observed effect level), ie the lowest dose above
which responses start occurring. Does anyone know how to do this?
[[alternative HTML version deleted]]
2004 Oct 26
2
vcov method for 'coxph' objects
Dear all,
The help file for the generic function vcov states
"Classes with methods for this function include: 'lm', 'glm', 'nls', 'lme',
'gls', 'coxph' and 'survreg' (the last two in package 'survival')."
Since, I am not able to use vcov.coxph(), I am wondering whether I am
missing something (as I suspect..)
regards,
vito
2002 Sep 18
3
problem in deparse(substitute())
Hi all,
I am experiencing the following quite strange (at least in my knowledge)
problem in a simple function like the following:
fn<-function(y,v=2){
n<-length(y)
y<-y[(v+1):(n-v)]
plot(y,type="l",lty=3,xlab="Time",ylab=deparse(substitute(y)))
}
fn(rnorm(50)) #look at the plot!!!
The plot appears with numbers on the left side!
If I delete the
2003 Mar 12
1
simulating 'non-standard' survival data
Dear all,
I'm looking for someone that help me to write an R function to simulate
survival data under complex situations, namely time-varying hazard ratio,
marginal distribution of survival times and covariates. The algorithm is
described in the reference below and it should be not very difficult to
implement it. However I tried but without success....;-(
Below there the code that I used; it
2001 Dec 03
1
fitting models with the subset argument
Hi all,
I'd like to fit model where the terms both are in the data.frame, mydata
say, and are vectors *not in the data.frame*.
>obj<-glm(y~x, data=mydata) #works
>Z<-pmax(mydata$x-20,0)
>(length(Z)==length(obj$y))
>[1] TRUE
>update(obj,.~.+Z) #works
However for some subset it doesn't works:
>obj<-glm(y~x, data=mydata, subset=f==1) #works
2009 Nov 02
3
partial matching with grep()
dear all,
This is a probably a silly question.
If I type
> grep("x",c("a.x" ,"b.x","a.xx"),value=TRUE)
[1] "a.x" "b.x" "a.xx"
Instead, I would like to obtain only
"a.x" "b.x"
How is it possible to get this result with grep()?
many thanks for your attention,
best,
vito
--
2007 Apr 03
3
Testing additive nonparametric model
I have estimated a multiple nonparametric regression using the loess
command in R. I have also estimated an additive version of the model using
the gam function. Is there a way of using the output of these two models to
test the restrictions imposed by the additive model?
2012 Mar 12
1
Fwd: Re[2]: B-spline/smooth.basis derivative matrices
--- On Mon, 3/12/12, aleksandr shfets <a_shfets at mail.ru> wrote:
> From: aleksandr shfets <a_shfets at mail.ru>
> Subject: Fwd: Re[2]: [R] B-spline/smooth.basis derivative matrices
> To: "Vassily Shvets" <shv736 at yahoo.com>
> Received: Monday, March 12, 2012, 5:15 PM
>
>
>
> -------- ???????????? ?????????
> --------
> ?? ????:
2018 Jan 30
2
variable names in lm formula ~.
dear all,
Is the following intentional? Am I missing anything in documentation?
d<-data.frame(y=rnorm(10,5,.5),exp=rnorm(10), age=rnorm(10))
formula(lm(exp(y)~exp+age, data=d))
#--> exp(y) ~ exp + age
formula(lm(exp(y)~., data=d))
#--> exp(y) ~ age
variable 'exp' (maybe indicating "experience") is not included in the
model. The same happens with 'log' (and
2007 Nov 28
3
using names with functions..
Dear all,
I have the following (rather) strange problem..
For some reasons, I finally work with a variable whose name includes an
R function, "a.log(z)", say. And that is a problem when I call it in a
formula, for instance:
> myname<-"a.log(z)"
> dd<-data.frame("a.log(z)"=1:10,y=rnorm(10))
> o<-lm(y~1,data=dd)
>
2024 Jul 26
1
Automatic Knot selection in Piecewise linear splines
dear all,
I apologize for my delay in replying you. Here my contribution, maybe
just for completeness:
Similar to "earth", "segmented" also fits piecewise linear relationships
with the number of breakpoints being selected by the AIC or BIC
(recommended).
#code (example and code from Martin Maechler previous email)
library(segmented)
o<-selgmented(y, ~x, Kmax=20,
2010 Mar 04
1
only actual variable names in all.names()
dear all,
When I use all.vars(), I am interest in extracting only the variable names..
Here a simple example
all.vars(as.formula(y~poly(x,k)+z))
returns
[1] "y" "x" "k" "z"
and I would like to obtain
"y" "x" "z"
Where is the trick?
many thanks
vito
--
====================================
Vito M.R. Muggeo
Dip.to Sc
2006 Feb 27
3
how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?
Hi all,
Could anybody recommend some easy-to-understand and example based
notes/tutorials on how to use cubic splines to do filtering on
multi-dimension data?
I am confused by the 1-dimensional case, and more confused by
multi-dimensional case.
I found all the books suddenly become very abstract when it comes to this
subject.
They don't provide examples in R or Splus at all.
Specifically,
2018 Jan 30
0
variable names in lm formula ~.
Functions are first class objects, so some kind of collision is bound to happen if you do this... so don't.
--
Sent from my phone. Please excuse my brevity.
On January 30, 2018 3:11:56 AM PST, "Vito M. R. Muggeo" <vito.muggeo at unipa.it> wrote:
>dear all,
>Is the following intentional? Am I missing anything in documentation?
>
2018 May 21
2
removing part of a string
dear all,
I am stuck on the following problem. Give a string like
ss1<- "z:f(5, a=3, b=4, c='1:4', d=2)"
or
ss2<- "f(5, a=3, b=4, c=\"1:4\", d=2)*z"
I would like to remove all entries within parentheses.. Namely, I aim to
obtain respectively
"z:f()" or "f()*z"
I played with sub() and gsub() but without success..
Thank you very
2007 Dec 06
1
differences in using source() or console
Dear all,
Is there *any* reason explaining what I describe below?
I have the following line
myfun(x)
If I type them directly in R (or copy/past), it works..
However if I type in R 2.6.1
> source("code.R") ##code.R includes the above line
Error in inherits(x, "data.frame") : object "d" not found
namely myfun() does not work correctly.
In particular the
2008 May 02
1
error in using by + median
dear all,
Could anyone explain me the behaviour of median() within by()?
(I am running R.2.7.0)
thanks,
vito
> H<-cbind(rep(0:1,l=20),matrix(rnorm(20*2),20,2))
> by(H[,-1],H[,1],mean)
INDICES: 0
V1 V2
-0.2101069 0.2954377
---------------------------------------------------------------------------------------------------------------------
INDICES: 1
V1