Displaying 20 results from an estimated 37 matches for "strt".
Did you mean:
start
2017 Aug 22
4
boot.stepAIC fails with computed formula
...t <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1)
#the real data won't have these names...
cn <- names(dat)
trg <- "y1"
xvars <- cn[cn!=trg]
frm1<-as.formula(paste(trg,"~1"))
frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))
strt=lm(y1~1,dat) # boot.stepAIC Works fine
#strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##
#strt=lm(frm1,dat) ## boot.stepAIC FAILS ##
limit<-5
stp=stepAIC(strt,direction='forward',steps=limit,
scope=list(lower=frm1,upper=frm2))
bst <- boot.ste...
2017 Aug 23
3
boot.stepAIC fails with computed formula
...Message-----
From: Bert Gunter [mailto:bgunter.4567 at gmail.com]
Sent: 22 August 2017 20:38
To: Stephen O'hagan <SOhagan at manchester.ac.uk>
Cc: r-help at r-project.org
Subject: Re: [R] boot.stepAIC fails with computed formula
OK, here's the problem. Continuing with your example:
strt1 <- lm(y1 ~1, dat)
strt2 <- lm(frm1,dat)
> strt1
Call:
lm(formula = y1 ~ 1, data = dat)
Coefficients:
(Intercept)
41.73
> strt2
Call:
lm(formula = frm1, data = dat)
Coefficients:
(Intercept)
41.73
Note that the formula objects of the lm object are different: strt2 d...
2017 Aug 23
0
boot.stepAIC fails with computed formula
It seems that if you build the formula as a character string, and
postpone the "as.formula" into the lm call, it works.
instead of
frm1 <- as.formula(paste(trg,"~1"))
use
frm1a <- paste(trg,"~1")
and then
strt <- lm(as.formula(frm1a),dat)
regards,
Heinz
Stephen O'hagan wrote/hat geschrieben on/am 23.08.2017 12:07:
> Until I get a fix that works, a work-around would be to rename the 'y1' column, used a fixed formula, and rename it back afterwards.
>
> Thanks for your help.
>...
2017 Aug 22
0
boot.stepAIC fails with computed formula
OK, here's the problem. Continuing with your example:
strt1 <- lm(y1 ~1, dat)
strt2 <- lm(frm1,dat)
> strt1
Call:
lm(formula = y1 ~ 1, data = dat)
Coefficients:
(Intercept)
41.73
> strt2
Call:
lm(formula = frm1, data = dat)
Coefficients:
(Intercept)
41.73
Note that the formula objects of the lm object are different: strt2
d...
2004 Jul 15
0
indexing a parameter in nls
...s on Y. If p=.5, f1 and f2 have equal impact, for
p>.5, f1 has greater impact, for p<.5 f2 has greater impact.
I can estimate the model as follows for f1="row", f2="col",
Y="nkids":
rd<-model.matrix(~as.factor(row)-1)
cd<-model.matrix(~as.factor(col)-1)
strt<-list(m1=2,m2=2,m3=2,m4=2,m5=3,p=.5)
nls(nkids~p*(rd[,1]*m1+rd[,2]*m2+rd[,3]*m3+rd[,4]*m4+rd[,5]*m5) +
(1-p)*(cd[,1]*m1+cd[,2]*m2+cd[,3]*m3+cd[,4]*m4+cd[,5]*m5),
start=strt)
---
What I want however, is a more compact specification, where "row" and
"col" are used...
2019 Sep 23
2
What is the best way to loop over an ALTREP vector?
Sorry for post a lot of things, for the first part of code, I copied my C++
iter macro by mistake(and you can see an explicit type casting). Here is
the macro definition from R_exts/Itermacros.h
#define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
strt, nfull, expr) do { \
* const** etype *px = DATAPTR_OR_NULL(sx); * \
if (px != NULL) { \
R_xlen_t __ibr_n__ = strt + nfull; \
R_xlen_t nb = __ibr_n__;...
2017 Aug 22
1
boot.stepAIC fails with computed formula
...> #the real data won't have these names...
>
> cn <- names(dat)
> trg <- "y1"
> xvars <- cn[cn!=trg]
>
> frm1<-as.formula(paste(trg,"~1"))
> frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))
>
> strt=lm(y1~1,dat) # boot.stepAIC Works fine
>
> #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##
>
> #strt=lm(frm1,dat) ## boot.stepAIC FAILS ##
>
> limit<-5
>
>
> stp=stepAIC(strt,direction='forward',steps=limit,
> scope=lis...
2017 Aug 22
1
boot.stepAIC fails with computed formula
SImplify your call to lm using the "." argument instead of
manipulating formulas.
> strt <- lm(y1 ~ ., data = dat)
and you do not need to explicitly specify the "1+" on the rhs for lm, so
> frm2<-as.formula(paste(trg," ~ ", paste(xvars,collapse = "+")))
works fine, too.
Anyway, doing this gives (but see end of output)"
bst <- boot.st...
2017 Aug 22
0
boot.stepAIC fails with computed formula
...hese names...
>>
>> cn <- names(dat)
>> trg <- "y1"
>> xvars <- cn[cn!=trg]
>>
>> frm1<-as.formula(paste(trg,"~1"))
>> frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+")))
>>
>> strt=lm(y1~1,dat) # boot.stepAIC Works fine
>>
>> #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ##
>>
>> #strt=lm(frm1,dat) ## boot.stepAIC FAILS ##
>>
>> limit<-5
>>
>>
>> stp=stepAIC(strt,direction='forward',ste...
2019 Oct 23
2
Unexpected behavior when using macro to loop over vector
...ros.h" to loop over an atomic vector. Here is a minimum
example:
C++ code
```
#include "R_ext/Itermacros.h"
#define GET_REGION_BUFSIZE 2
//Redefine the macro since C++ is not happy with the implicit type
conversion
#define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
strt, nfull, expr) do { \
const etype *px = (etype*)DATAPTR_OR_NULL(sx); \
if (px != NULL) { \
R_xlen_t __ibr_n__ = strt + nfull; \
R_xlen_t nb = __ibr_n__; \
for (R_xlen_t idx = strt; idx < __ibr_n__; idx += nb) { \
expr \
} \
} \
else ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype,...
2019 Oct 25
2
Unexpected behavior when using macro to loop over vector
...gt;> C++ code
>> ```
>> #include "R_ext/Itermacros.h"
>> #define GET_REGION_BUFSIZE 2
>> //Redefine the macro since C++ is not happy with the implicit type
>> conversion
>> #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
>> ? strt, nfull, expr) do { \
>> const etype *px = (etype*)DATAPTR_OR_NULL(sx); \
>> if (px != NULL) { \
>> ??? R_xlen_t __ibr_n__ = strt + nfull; \
>> ??? R_xlen_t nb = __ibr_n__; \
>> ??? for (R_xlen_t idx = strt; idx < __ibr_n__; idx += nb) { \
>> expr \
>> ??...
2019 Sep 24
2
What is the best way to loop over an ALTREP vector?
...I copied my
> C++
> > iter macro by mistake(and you can see an explicit type casting). Here is
> > the macro definition from R_exts/Itermacros.h
> >
> > #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
> >
> > strt, nfull, expr) do { \
> >
> > * const** etype *px = DATAPTR_OR_NULL(sx); *
> \
> >
> > if (px != NULL) { \
> >
> > R_xlen_t __ibr_n__ = strt + nfull; \
> >...
2019 Sep 24
0
What is the best way to loop over an ALTREP vector?
...ings, for the first part of code, I copied my C++
> iter macro by mistake(and you can see an explicit type casting). Here is
> the macro definition from R_exts/Itermacros.h
>
> #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
>
> strt, nfull, expr) do { \
>
> * const** etype *px = DATAPTR_OR_NULL(sx); * \
>
> if (px != NULL) { \
>
> R_xlen_t __ibr_n__ = strt + nfull; \
>
> R_xlen_t...
2019 Aug 28
3
What is the best way to loop over an ALTREP vector?
Hi devel team,
I'm working on C/C++ level ALTREP compatibility for a package. The package
previously used pointers to access the data of a SEXP, so it would not work
for some ALTREP objects which do not have a pointer. I plan to rewrite the
code and use functions like get_elt, get_region, and get_subset to access
the values of a vector, so I have a few questions for ALTREP:
1. Since an
2011 Sep 22
1
nlm's Hessian update method
...mber of different ways to do this, and seems to conclude that the positive-definite secant method (BFGS) works best in practice (p201). However, when I run my code through the optim function with the method as "BFGS", slightly different estimates are produced to that of nlm:
> optim(strt,jointll2,method="BFGS",hessian=T)$par
-0.4016808 0.6057144 0.3744790 -7.1819734 3.0230386 0.4446641
> nlm(jointll2,strt,hessian=T)$estimate
[1] -0.4016825 0.6057159 0.3744765 -7.1819737 3.0230386 0.4446623
Can anyone tell me if nlm employs the BFGS method f...
2006 Jul 21
2
glm cannot find valid starting values
glm(S ~ -1 + Mdif, family=quasipoisson(link=identity), start=strt, sdat)
gives error:
> Error in glm.fit(x = X, y = Y, weights = weights, start = start, etastart
> =
> etastart, :
> cannot find valid starting values: please specify some
strt is set to be the coefficient for a similar fit
glm(S ~ -1 + I(Mdif + 1),...
i.e. (Mdif + 1) is a vec...
2008 Dec 02
2
question about the tisPlot function in package tis
...djusted the
frequency of their x-axis label using this package before? I imagine that
there must be a better way of doing what I am trying to accomplish, but if
not, does anyone have a suggestion on how to work around this without
digging into the function itself?
## an example
library(tis)
strt <- ti(20000101, "monthly")
dat <- tis(runif(9*12 - 1), start=strt) # ends in 11/2008
par(mfrow=c(2,1))
tisPlot(dat, xTickFreq="monthly", xTickSkip=6) # graph ends in 11/2008,
but looks to start some time in late 1999
tisPlot(dat, xTickFreq="monthly", xTickSkip...
2011 Feb 03
3
coxph fails to survfit
I have a model with quant vars only and the error message does not make sense:
(mod1 <- coxph(Surv(time=strt,time2=stp,event=(resp==1))~ +incpost+I(amt/1e5)+rate+strata(termfac),
subset=dt<"2010-08-30", data=inc,method="efron"))
Call:
coxph(formula = Surv(time = strt, time2 = stp, event = (resp ==
1)) ~ +incpost + I(amt/1e+05) + rate + strata(termfac), data = inc,...
2019 Oct 25
0
Unexpected behavior when using macro to loop over vector
...s a minimum
> example:
>
> C++ code
> ```
> #include "R_ext/Itermacros.h"
> #define GET_REGION_BUFSIZE 2
> //Redefine the macro since C++ is not happy with the implicit type
> conversion
> #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
> strt, nfull, expr) do { \
> const etype *px = (etype*)DATAPTR_OR_NULL(sx); \
> if (px != NULL) { \
> R_xlen_t __ibr_n__ = strt + nfull; \
> R_xlen_t nb = __ibr_n__; \
> for (R_xlen_t idx = strt; idx < __ibr_n__; idx += nb) { \
> expr \
> } \
> } \
> else IT...
2019 Sep 23
0
What is the best way to loop over an ALTREP vector?
...sion(const void * to const int
*), see below. While it is allowed in C, C++ seems not happy with it. Is it
possible to add an explicit type casting so that it can be compatible with
both language?
#define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype, vtype, \
strt, nfull, expr) do { \
*const etype *px = (const** etype *)DATAPTR_OR_NULL(sx); *
\
if (px != NULL) { \
R_xlen_t __ibr_n__ = strt + nfull; \
R_xlen_t nb = __ibr_n__;...