[R] error in mixed logit model using mlogit function

2014-05-14 Thread danielle
Dear all,

I am trying to estimate an mlm with 8 alternatives, but I received the
following error message:

Error in `colnames<-`(`*tmp*`, value = "disto.disto") : 
  attempt to set colnames on object with less than two dimensions

My data look like this:

> head(dtb)
  votechoice disto.CVP disto.FDP disto.GPS disto.LPS disto.PBD  disto.SP
disto.SVP  disto.VL risk
1GPS 1.3797308 2.1734424 0.7447605 2.7584803 2.1036997 1.2393141 
4.320573 0.70274439
2SVP 1.6202692 0.8265576 3.7447605 0.2415197 0.8963003 4.2393141 
1.320573 2.29725572
3CVP 0.6202692 0.1734424 2.7447605 0.7584803 0.1036997 3.2393141 
2.320573 1.29725573
4SVP 4.6202692 3.8265576 6.7447605 3.2415197 3.8963003 7.2393141 
1.679427 5.29725579
5SVP 2.6202692 1.8265576 4.7447605 1.2415197 1.8963003 5.2393141 
0.320573 3.29725576
6GPS 2.3797308 3.1734424 0.2552395 3.7584803 3.1036997 0.2393141 
5.320573 1.70274434

When I estimate a simple logit model it is working:

rpl2 <- mlogit(votechoice ~ disto | risk,data=newdtb, shape =
'wide',varying=2:9, correlation=T,
halton = NA,R = 10, tol = 10, print.level = 0);summary(rpl2)

but when I am trying to estimate an mlm, I get the following: 

> rpl2 <- mlogit(votechoice ~ disto | risk,data=newdtb, shape =
> 'wide',varying=2:9,correlation=T,
+ rpar=c(disto='l'),halton = NA,R = 10, tol = 10, print.level = 2)

Error in `colnames<-`(`*tmp*`, value = "disto.disto") : 
  attempt to set colnames on object with less than two dimensions


I would be grateful for any help, thanks for reading this post.
danielle







--
View this message in context: 
http://r.789695.n4.nabble.com/error-in-mixed-logit-model-using-mlogit-function-tp4690489.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] error message - unexpected input

2009-10-08 Thread Danielle Dandreaux
I have been using R the past couple of years to run models on data we
are collecting. I recently got a new computer and updated to a new
version of R (2.60 -> 2.90). Since the update, I cannot get my syntax to
run. I have tried copying the file it is looking for into many different
directories to try and run it. In the last version, I found that it was
easiest if the file was copied into the R program file folder. I have
also tried changing the font the code is written in and turning off
"smart quotes" in MS word. Additionally, I have right clicked on R and
set myself as the only user on this computer to run this program. The
syntax line that appears to be causing problems is:
dataname="Igt2model.txt" and the error message is: Error: unexpected
input in "dataname=""

 

Does anyone have any suggestions?

 

Thanks for all of your help,

Danielle

 

Danielle Dandreaux, Ph.D.

Faculty Research Associate

Arizona State University

Department of Psychology

Tempe, AZ 85287

480-965-3053

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] creating multiple plots using a splitting factor

2009-11-09 Thread Johnston, Danielle
Hello,

 

I am new to R.  I often collect data at multiple sites and need to
create separate graphs (such as scatterplots or histograms) of specific
variables for each site.  I have tried to do this by splitting the data
frame and then using lapply, but it seems that the graphing commands
cannot be called as functions.  Here is a sample of my data, called
"seeddist2":

 

   siteDaysSinceRelease   distance_cm

10  GVM   1   17.8

11  GVM   1   17.8

12  GVM   1   14.0

13  GVM   1   14.0

14  GVM   1   14.9

15  GVM   1   25.4

16  WRR   1   25.4

17  WRR   1   35.0

18  WRR   1   45.0

19  WRR   1   55.0

20  WRR   1   60.0

 

Here is what I tried to get separate histograms of distance_cm by site:

splitlist<- split(seeddist2, site)

lapply(splitlist, hist(distance_cm, breaks=10))

 

I then get an error message saying that "match.fun" didn't find the
function.  Is there another way to produce multiple graphs at once?

 

Thank you,

 

Danielle B. Johnston, Habitat Researcher

Colorado Division of Wildlife

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] creating multiple plots using a splitting factor

2009-11-10 Thread Johnston, Danielle
Thank you for the responses.  The Lattice library is indeed useful for
producing the graphs in which I am interested, and I appreciate the
clarification between a function and the result of a function.  

Ideally, I would like to be able to page through the graphs rather than
(or in addition to) having them displayed on the same page.  Is there a
way to do this?

Danielle B. Johnston, Habitat Researcher
Colorado Division of Wildlife

-Original Message-
From: Phil Spector [mailto:spec...@stat.berkeley.edu] 
Sent: Tuesday, November 10, 2009 12:46 AM
To: Johnston, Danielle
Subject: Re: [R] creating multiple plots using a splitting factor

Danielle -
What you meant to say was

lapply(splitlist, function(x)hist(x$distance_cm, breaks=10))

but you might also be interested in trying

library(lattice)
histogram(~distance_cm|site,data=seeddist2)


- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu




On Mon, 9 Nov 2009, Johnston, Danielle wrote:

> Hello,
>
>
>
> I am new to R.  I often collect data at multiple sites and need to
> create separate graphs (such as scatterplots or histograms) of
specific
> variables for each site.  I have tried to do this by splitting the
data
> frame and then using lapply, but it seems that the graphing commands
> cannot be called as functions.  Here is a sample of my data, called
> "seeddist2":
>
>
>
>   siteDaysSinceRelease   distance_cm
>
> 10  GVM   1   17.8
>
> 11  GVM   1   17.8
>
> 12  GVM   1   14.0
>
> 13  GVM   1   14.0
>
> 14  GVM   1   14.9
>
> 15  GVM   1   25.4
>
> 16  WRR   1   25.4
>
> 17  WRR   1   35.0
>
> 18  WRR   1   45.0
>
> 19  WRR   1   55.0
>
> 20  WRR   1   60.0
>
>
>
> Here is what I tried to get separate histograms of distance_cm by
site:
>
> splitlist<- split(seeddist2, site)
>
> lapply(splitlist, hist(distance_cm, breaks=10))
>
>
>
> I then get an error message saying that "match.fun" didn't find the
> function.  Is there another way to produce multiple graphs at once?
>
>
>
> Thank you,
>
>
>
> Danielle B. Johnston, Habitat Researcher
>
> Colorado Division of Wildlife
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error in anova.cca by="axis" after Vegan update

2013-06-05 Thread Edwards, Danielle
Hi,

I am trying to replicate some code I previously used to undertake a dbRDA
analysis, however since updating my R software and all associated packages
to the latest version it seems the analysis does not work.

I have two dist objects: gendist and geodist.

I first reduce geodist using pcnm().

geo_pcnm<-pcnm(geodist)

I then use these scores in capscale().

geo_rda<-capscale(gendist~scores(geo_pcnm))

To forward select the variables to use in further analyses, so I want to
know which ones are significant - and herein lies my problem.

After running:

anova(geo_rda,by="axis",perm=)

I get the following error:

Error in eval(expr, envir, enclos) : could not find function "Condition"

I have run traceback() and this is what I get:

traceback()
14: eval(expr, envir, enclos)
13: eval(predvars, data, env)
12: model.frame.default(formula, data, na.action = na.pass, xlev = xlev)
11: model.frame(formula, data, na.action = na.pass, xlev = xlev)
10: ordiParseFormula(fla, if (is.data.frame(data) && !is.null(comm))
cbind(data,
comm) else data, envdepth = 1, na.action = na.action, subset =
substitute(subset))
9: capscale(formula = gendist ~ CAP1 + Condition(CAP2 + CAP3 + CAP4 +
   CAP5 + CAP6 + CAP7 + CAP8 + CAP9 + CAP10 + CAP11 + CAP12 +
   CAP13 + CAP14 + CAP15 + CAP16 + CAP17 + CAP18 + CAP19 + CAP20 +
   CAP21 + CAP22 + CAP23 + CAP24 + CAP25 + CAP26 + CAP27 + CAP28 +
   CAP29 + CAP30 + CAP31 + CAP32 + CAP33 + CAP34 + CAP35 + CAP36 +
   CAP37 + CAP38 + CAP39 + CAP40 + CAP41 + CAP42 + CAP43 + CAP44 +
   CAP45 + CAP46 + CAP47 + CAP48 + CAP49 + CAP50 + CAP51 + CAP52 +
   CAP53 + CAP54 + CAP55 + CAP56 + CAP57 + CAP58 + CAP59 + CAP60 +
   CAP61 + CAP62 + CAP63 + CAP64 + CAP65), data = lc)
8: eval(expr, envir, enclos)
7: eval(call, parent.frame())
6: update.default(object, fla, data = lc)
5: update(object, fla, data = lc)
4: anova(update(object, fla, data = lc), ...)
3: anova.ccabyaxis(object, alpha = alpha, beta = beta, step = step,
   perm.max = perm.max, by = NULL, ...)
2: anova.cca(geo_rda, by = "axis", perm = )
1: anova(geo_rda, by = "axis", perm = )




Is this a problem with the update? This code has worked multiple times for
me in the past using older versions.

Cheers
Dan

Dan Edwards
Postdoctoral Research Associate
Department of Ecology & Evolutionary Biology
Yale University
21 Sachem St, New Haven CT 06520
E: danielle.edwa...@yale.edu
W: https://sites.google.com/site/drdanielleedwards/


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Best way to specify a mixed ANCOVA in R?

2013-09-20 Thread Danielle Smith
I initially posted this question to one of the StackExchange sites, and they 
suggested that I repost my problem here.

After using ezANOVA as my primary way of specifying mixed ANOVAs, I've hit a 
stumbling block when it come to adding a covariate to the model. I am using an 
ANCOVA in order to determine if there is a developmental trajectory in my data; 
namely, I need to be able to see the F-statistic and p-values for interactions 
with the covariate (see p.466 onwards here 
[http://www.psyc.bbk.ac.uk/research/DNL/personalpages/annaz_etal_2009.pdf] if 
you want an example).

Using ezANOVA, I can include covariates but the output does not show the 
F-statistic and p-values for interactions with the covariate - the main effect 
of the covariate is also not tested using this method.

My ezANOVA model is as follows:

aov.model<-ezANOVA(
data=textureView.child.outliersRemoved
, dv=.(x)
, wid=.(ID)
, within=.(Texture,View)
, between=.(TNOGroup)
, between_covariates=.(Age)
, type=3
, return_aov=TRUE
)

Another option is to use lm or Anova, but I don't know how to specify the error 
terms properly for either and I'm limited because I want to use Type-III sums 
of squares (drop1 doesn't work in the cases where I've tried to use the aov 
wrapper for lm; it fails while reporting 'Error in formula.default(object, env 
= baseenv()) : invalid formula').

Finally, I've heard about using the nlme package to specify my ANCOVA as a 
mixed model instead, but I don't know where to begin here (despite spending a 
while reading about it).

To give a summary, I'm trying to do a 2 (between; TNOGroup) x 2 (within, 
Texture) x2 (within, View) mixed ANCOVA, with age as a covariate. I want to use 
Type-III sums of squares, and see the F-statistic and p-values for interactions 
with the covariate, as well as for the main effect of the covariate.

Any advice on the best way to do this would be much appreciated.

Thanks,
Danielle
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Looping over graphs in igraph

2011-05-05 Thread Danielle Li
Hi,


I'm trying to do some basic social network analysis with igraph in R, but
I'm new to R and haven't been able to find documentation on a couple basic
things:

I want to run igraph's community detection algorithms on a couple thousand
small graphs but don't know how to automate igraph looking at multiple
graphs described in a single csv file.  My data look like something in ncol
format, but with an additional column that has an ID for which graph the
edge belongs in:


Graph ID | Vertex1 | Vertex2 | weight

1 | Alice | Bob | 2

1 | Alice | Chris | 1

1 | Alice | Jane | 2

1 | Bob | Jane | 2

1 | Chris | Jane | 3


2 | Alice | Tom | 2

2 | Alice | Kate | 1

2 | Kate | Tom | 3

2 | Tom | Mike | 2


so on and so forth for about 2000 graph IDs, each with about 20-40
vertices.  I've tried using the "split" command but it doesn't recognize my
graph id: ("object 'graphid' not found)--this may just be because I don't
know how to classify a column of a csv as an object.


Ultimately, I want to run community detection on each graph separately--to
look only at the edges when the graph identifier is 1, make calculations on
that graph, then do it again for 2 and so forth.  I suspect that this isn't
related to igraph specifically--I just don't know the equivalent command in
R for what in pseudo Stata code would read as:


forvalues i of 1/N {

temp_graph=subrows of the main csv file for which graphid==`i'

cs`i' = leading.eigenvector.community.step(temp_graph)
convert cs`i'$membership into a column in the original csv

}


I want the output to look something like:


Graph ID | Vertex1 | Vertex2 | weight | Vertex 1 membership | Vertex 2
membership | # of communities in the graph


1 | Alice | Bob | 2 | A | B | 2

1 | Alice | Chris | 1 | A | B | 2

1 | Alice | Jane | 2 | A | B | 2

1 | Bob | Jane | 2 | B | B | 2

1 | Chris | Jane | 3 | B | B | 2


 2 | Alice | Tom | 2 | A | B | 3

2 | Alice | Kate | 1 | A | C | 3

2 | Kate | Tom | 3 |  C | B | 3

2 | Tom | Mike | 2 | B | C | 3


Here, the graphs are treated completely separately so that community A in
graph 1 need not have anything to do with community A in graph 2.


I would really appreciate any ideas you guys have.


Thank you!

Danielle

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] multinomRob - error message

2011-08-17 Thread Danielle Martin

Hi,

I would like to use the multinomRob function to test election results.  
However, depending on which independent variables I include and how  
many categories I have in the dependent variable, the model cannot be  
estimated.


My data look like this (there are 68 observations):


head(database)

   RESTE09 GAUCHE09 PDC09 PLR09 UDC09 MCG09RESTE05  GAUCHE05  PDC05
D11455 5931  4726  7283  3611  5179 0.04487642 0.1707559 0.27561790
D2173610548  6905 27660  5430  5360 0.04487109 0.1797425 0.13782229
D3420812452  1721  8210  3179  8960 0.18580836 0.3218897 0.05659316
D42182 9208  7288 10654  2951  5205 0.08227831 0.2591124 0.19605699
D5612913909 12691 15560  3129 12551 0.10438878 0.2362780 0.23772964
D6302713517  4702 17899  5299  5758 0.10507522 0.2034102 0.07564233
   PLR05  UDC05  MCG05   dim1dim2dim3
D1 0.3006495 0.08555836 0.12254194  0.4327918 -0.37563170  0.23139759
D2 0.4879385 0.09903729 0.05058832  1.2723817  0.03128996 -0.10629471
D3 0.2296300 0.07822276 0.12785602 -0.8002237 -0.12194377  0.18147181
D4 0.3051325 0.06789533 0.08952449  0.4321835  0.11445829  0.24636903
D5 0.2811336 0.06624300 0.07422700  0.2560408  0.07019505  0.05611872
D6 0.4186317 0.10281440 0.09442613  0.4487914 -0.15539599 -0.04779844



I defined the model as follows:


mnr<-multinomRob(list(

+ GAUCHE09~GAUCHE05+dim1+dim2+dim3,
+ PDC09~PDC05+dim1+dim2+dim3,
+ PLR09~PLR05+dim1+dim2+dim3,
+ UDC09~UDC05+dim1+dim2+dim3,
+ MCG09~MCG05+dim1+dim2+dim3,
+ RESTE09~0),database,print.level=0)


And the error message is:

Error in multinomT.foo$se$beta : $ operator is invalid for atomic vectors
In addition: There were 11 warnings (use warnings() to see them)


warnings()

Warning messages:
1: In optim(param, fn = mt.dev, method = method, control = control,  ... :
  unknown names in control: tol
2: In fn(par, ...) : value out of range in 'lgamma'
3: In fn(par, ...) : value out of range in 'lgamma'
4: In fn(par, ...) : value out of range in 'lgamma'
5: In fn(par, ...) : value out of range in 'lgamma'
6: In fn(par, ...) : value out of range in 'lgamma'
7: In fn(par, ...) : value out of range in 'lgamma'
8: In fn(par, ...) : value out of range in 'lgamma'
9: In fn(par, ...) : value out of range in 'lgamma'
10: In fn(par, ...) : value out of range in 'lgamma'
11: In fn(par, ...) : value out of range in 'lgamma'


Is my model uncorrectly defined?

many thanks,

danielle martin
graduate student
department of political science
university of michigan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Survdiff for multiple comparisons

2011-07-21 Thread Danielle Zoellner
Hello all-

I am doing a survival analysis for two species of invasive plants I
outplanted to edges and interiors of island and mainland sites in a local
reservoir.  I am using the KM estimate and had no problem doing survdiff for
my data using the following code:

S4<-Surv(outplant$SurvTime, outplant$StatusD6)
diff4=survdiff(S4 ~ outplant$Species+outplant$SiteType+outplant$EdgInt)
diff4

Species = ALBIJU or LONIJA
SiteType = Island or Mainland
EdgInt = Edge or Interior

The overall test for difference among the 8 curves is highly significant
(p<0.001), but what I would like to know is how I would go about testing for
pairwise differences among the eight curves, as what is most informative
would be pinpointing exactly which curves are significantly different from
each other for each species.  I have not been able to find any code or
function out there that will give me this test with adjusted p-values.  I
was thinking about using subset, but this will not adjust the p-values for
multiple tests.

Thank you for your time - Danielle

-- 
Danielle C. Zoellner-Kelly
PhD candidate - DeWalt Lab
Department of Biological Sciences
Clemson University
132 Long Hall
Clemson, SC   29634
Lab:  (864) 656-2639
Cell:  (864) 376-9583

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logistic Regression with genetic component

2011-12-03 Thread Danielle Duncan
Greetings, I have a question that I'd like to get input on. I have a
classic toxicology study where I artificially fertilized and exposed
embryos to a chemical and counted defects. In addition, I kept track of
male-female pairs that I used to artificially fertilize and generate
embryos with. I need to use logistic regression to model the response, but
also check that the genetics of the pairings did or did not have an effect
on the response. My data looks a bit like this:

response matrix chemical concentration  Genetic Matrix
Present AbsentMale Female
2 152   0.13 a 1
6 121  1 a 2
21 92  2 b 3
24 89  5 b 4
0141 10 c 5
5 95 15 c  6

R code:

DA<-cbind(Present, Absent)
glm<-(DA ~ chemical concentration)

If I do glm<-(DA ~ chemical concentration + Male + Female, I get every
possible combination, but I only want specific pairs. So, I am thinking
about doing:

MF<-cbind(Male, Female)
glm<-(DA ~ chemical concentration + MF)

Is this correct? Any help on how to model this would be greatly
appreciated! Thanks in advance!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Calculating NOEL using R and logistic regression - Toxicology

2012-04-02 Thread Danielle Duncan
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]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculating NOEL using R and logistic regression - Toxicology

2012-04-03 Thread Danielle Duncan
Thanks, that is interesting, but what I'm really after is an easy "no
observed effect level", using a binomial logistic model ie glm. Have a
great day!

On Mon, Apr 2, 2012 at 3:38 PM, vito.muggeo  wrote:

> dear Danielle,
>
> The NOEL is a threshold value or breakpoint in the range of dose. Have a
> look to the
> package segmented to estimate a GLM with unknown breakpoints. The code
> (untested) should
> be something like
>
> library(segmented)
> o<-glm(y~1, family=binomial)
> os<-segmented(o, ~dose, psi=starting_psi)
>
> Also the package segmented includes the dataset down that can be useful as
> an example..
>
> data(down)
> with(down, plot(age, cases/births))
>
> There is a paper of mine on R news 2008 discussing the package..
>
> hope this helps you,
> vito
>
>
>
> On Mon, 2 Apr 2012 14:45:06 -0800, Danielle Duncan wrote
> > 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]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
> --
> Open WebMail Project (http://openwebmail.org)
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculating NOEL using R and logistic regression - Toxicology

2012-04-03 Thread Danielle Duncan
Thanks for the response, I should have clarified that the NOEL is the
smallest dose above which there is a statistically significant effect.

On Tue, Apr 3, 2012 at 12:44 PM, Drew Tyre  wrote:

> Is this the smallest observed dose that has an effect? If so, then you
> don't need the glm to find it. Here is a simulated example:
>
> set.seed(101)
> X = rep(1:10,each=10)
> lp = -5 + 0.5*X
> Y = rbinom(length(X),size=1,p=1/(1+exp(-lp)))
> # is this the NOEL?
> min(X[Y==1]) # picks out observations with adverse effects, chooses the
> smallest value
> glmfit = glm(Y~X,family=binomial)
> plot(1:10, predict(glmfit,newdata=data.frame(X=1:10),type="response"),
> type="l",ylim=c(0,1),xlab="X",ylab="Y")
> rug(jitter(X[Y==0]),side=1)
> rug(jitter(X[Y==1]),side=3)
>
> On Tue, Apr 3, 2012 at 3:19 PM, Danielle Duncan wrote:
>
>> Thanks, that is interesting, but what I'm really after is an easy "no
>> observed effect level", using a binomial logistic model ie glm. Have a
>> great day!
>>
>> On Mon, Apr 2, 2012 at 3:38 PM, vito.muggeo  wrote:
>>
>> > dear Danielle,
>> >
>> > The NOEL is a threshold value or breakpoint in the range of dose. Have a
>> > look to the
>> > package segmented to estimate a GLM with unknown breakpoints. The code
>> > (untested) should
>> > be something like
>> >
>> > library(segmented)
>> > o<-glm(y~1, family=binomial)
>> > os<-segmented(o, ~dose, psi=starting_psi)
>> >
>> > Also the package segmented includes the dataset down that can be useful
>> as
>> > an example..
>> >
>> > data(down)
>> > with(down, plot(age, cases/births))
>> >
>> > There is a paper of mine on R news 2008 discussing the package..
>> >
>> > hope this helps you,
>> > vito
>> >
>> >
>> >
>> > On Mon, 2 Apr 2012 14:45:06 -0800, Danielle Duncan wrote
>> > > 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]]
>> > >
>> > > __
>> > > R-help@r-project.org mailing list
>> > > https://stat.ethz.ch/mailman/listinfo/r-help
>> > > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > > and provide commented, minimal, self-contained, reproducible code.
>> >
>> >
>> > --
>> > Open WebMail Project (http://openwebmail.org)
>> >
>> >
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Drew Tyre
>
> School of Natural Resources
> University of Nebraska-Lincoln
> 416 Hardin Hall, East Campus
> 3310 Holdrege Street
> Lincoln, NE 68583-0974
>
> phone: +1 402 472 4054
> fax: +1 402 472 2946
> email: aty...@unl.edu
> http://snr.unl.edu/tyre
> http://aminpractice.blogspot.com
> http://www.flickr.com/photos/atiretoo
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculating NOEL using R and logistic regression - Toxicology

2012-04-04 Thread Danielle Duncan
Thanks everyone for the advice, you raise interesting points. Maybe the
best thing for me to do is do an ANOVA in R with binomial data (if
possible) and find the lowest dose that gives a significant difference from
the controls.

On Mon, Apr 2, 2012 at 2:45 PM, Danielle Duncan wrote:

> 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?




-- 
"Wilderness isn’t the wide open spaces. It’s the wild things in it”

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculating NOEL using R and logistic regression - Toxicology

2012-04-04 Thread Danielle Duncan
I suppose I'll just report a LC10 using the dose.p function in the package
MASS using my glm fitted logistic regression on binomial data. Thanks
everyone for ideas & input! The LOEC seems to be a flawed
calculation...I'll research it. Again, thanks all!

On Mon, Apr 2, 2012 at 2:45 PM, Danielle Duncan wrote:

> 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?




-- 
"Wilderness isn’t the wide open spaces. It’s the wild things in it”

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.