[R] is there colNA for a image? (i.e. How to set the color of NAs or background in an image)

2012-08-04 Thread Camilo Mora

Hi everyone,

I am using a layout of two images, one of which is an image of a  
raster. In this one image I am using a color palette to show the  
gradient of temperature in the world.By default the color of the  
continents (which I set to NA in the raster) appears as white.


I would like the NA values or background of just that one image to be  
of a given color. is this possible?


I know I can use bg in par but that will change the background color  
of the entire window.
I found I can use plot instead of image, which has the option of  
setting colNA to any color. My problem is that that the plot does  
not work well in the layout with the other image.


Any help very much appreciated.
Again, my question is how to set the background color of an image in a  
layout?.


Thanks,

Camilo

Camilo Mora, Ph.D.
Department of Geography, University of Hawaii

__
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] How to concatenate a several rows according with a column ?

2012-08-04 Thread arun


HI,
Try this:
#Reformatted the ddply results to match your desired output.
dat1-read.table(text=
   a    b c d
  E001234  TSA    IP234   like_domain
  E001234  TSB    IP234   like_domain    
  E001234  TSC    IP234   like_domain
  E001234  TSD    IP234   like_domain
  E001235  TSA    IP235   two_domain
  E001235  TSD    IP235   two_domain
  E001235  TSS    IP235   two_domain
  E001236  TSP    IP236   like_domain
  E001236  TST    IP236   like_domain
    E001237  TSV    IP237   simple_domain 
,sep=,header=TRUE,stringsAsFactors=FALSE)

dat2-ddply(dat1,.(a,c,d), paste,sep=,)
dat2-dat2[,c(1,5,2:3)]
colnames(dat2)-colnames(dat1)
dat3-data.frame(sapply(dat2,function(x) gsub(c|\\(|\\\|\\),,x)))
dat3
#    a  b c d
#1 E001234 TSA, TSB, TSC, TSD IP234   like_domain
#2 E001235  TSA, TSD, TSS IP235    two_domain
#3 E001236   TSP, TST IP236   like_domain
#4 E001237    TSV IP237 simple_domain

A.K.


- Original Message -
From: tgodoy tingola...@hotmail.com
To: r-help@r-project.org
Cc: 
Sent: Friday, August 3, 2012 1:00 PM
Subject: [R] How to concatenate a several rows according with a column ?

Hi, I'm a new user or R and I try to concatenate a several rows according
with the value in a column. 

this is my data.frame and I want to concatenate my data.frame according with
the column b and make a new data.frame with the information in the others
columns. 

table1
         a                    b         c             d
1      E001234      TSA    IP234   like_domain
2      E001234      TSB    IP234   like_domain    
3      E001234      TSC    IP234   like_domain
4      E001234      TSD    IP234   like_domain
5      E001235      TSA    IP235   two_domain
6      E001235      TSD    IP235   two_domain
7      E001235      TSS    IP235   two_domain
8      E001236      TSP    IP236   like_domain
9      E001236      TST    IP236   like_domain
10    E001237      TSV    IP237   simple_domain

I want my table in this way

table_new
         a                    b                                      c          
  
d
1      E001234      TSA, TSB, TSC, TSD    IP234   like_domain
2      E001235                TSA, TSD, TSS    IP235   two_domain
3      E001236                 TSP, TSP, TST    IP236   like_domain
4      E001237                                   TSV    IP237  
simple_domain

How can I do this in R? 

Thanks 




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-concatenate-a-several-rows-according-with-a-column-tp4639072.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-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] How to concatenate a several rows according with a column ?

2012-08-04 Thread David Winsemius


On Aug 3, 2012, at 10:00 AM, tgodoy wrote:

Hi, I'm a new user or R and I try to concatenate a several rows  
according

with the value in a column.

this is my data.frame and I want to concatenate my data.frame  
according with
the column b and make a new data.frame with the information in the  
others

columns.


table1 - -read.table(text=
ab c d
1  E001234  TSAIP234   like_domain
2  E001234  TSBIP234   like_domain
3  E001234  TSCIP234   like_domain
4  E001234  TSDIP234   like_domain
5  E001235  TSAIP235   two_domain
6  E001235  TSDIP235   two_domain
7  E001235  TSSIP235   two_domain
8  E001236  TSPIP236   like_domain
9  E001236  TSTIP236   like_domain
10E001237  TSVIP237
simple_domain,header=TRUE,stringsAsFactors=FALSE)


 aggrdat - with(table1, aggregate(b, list(a,c,d), FUN=paste,  
sep=,) )

 names(aggrdat) - names(table1)[c(2:4,1)]
 aggrdat
b c d  a
1 E001234 IP234   like_domain TSA, TSB, TSC, TSD
2 E001236 IP236   like_domain   TSP, TST
3 E001237 IP237 simple_domainTSV
4 E001235 IP235two_domain  TSA, TSD, TSS

Swapping the column position is left as an exercise.

--
David.


I want my table in this way


table_new

ab  c
d
1  E001234  TSA, TSB, TSC, TSDIP234   like_domain
2  E001235TSA, TSD, TSSIP235   two_domain
3  E001236 TSP, TSP, TSTIP236   like_domain
4  E001237   TSVIP237
simple_domain

How can I do this in R?

Thanks




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-concatenate-a-several-rows-according-with-a-column-tp4639072.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.


David Winsemius, MD
Alameda, CA, USA

__
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] How to concatenate a several rows according with a column ?

2012-08-04 Thread Rui Barradas

Hello,

Inline.

Em 04-08-2012 09:34, David Winsemius escreveu:


On Aug 3, 2012, at 10:00 AM, tgodoy wrote:

Hi, I'm a new user or R and I try to concatenate a several rows 
according

with the value in a column.

this is my data.frame and I want to concatenate my data.frame 
according with
the column b and make a new data.frame with the information in the 
others

columns.


table1 - -read.table(text=
ab c d
1  E001234  TSAIP234   like_domain
2  E001234  TSBIP234   like_domain
3  E001234  TSCIP234   like_domain
4  E001234  TSDIP234   like_domain
5  E001235  TSAIP235   two_domain
6  E001235  TSDIP235   two_domain
7  E001235  TSSIP235   two_domain
8  E001236  TSPIP236   like_domain
9  E001236  TSTIP236   like_domain
10E001237  TSVIP237 
simple_domain,header=TRUE,stringsAsFactors=FALSE)


 aggrdat - with(table1, aggregate(b, list(a,c,d), FUN=paste, sep=,) )
 names(aggrdat) - names(table1)[c(2:4,1)]


It's a column order issue, not a names one. Using Jean's form of aggregate,


aggrdat - aggregate(b ~ a + c + d, data = table1, paste, sep=,)
(table2 - aggrdat[, c(1, 4, 2, 3)])

Hope this helps,

Rui Barradas


 aggrdat
b c d  a
1 E001234 IP234   like_domain TSA, TSB, TSC, TSD
2 E001236 IP236   like_domain   TSP, TST
3 E001237 IP237 simple_domainTSV
4 E001235 IP235two_domain  TSA, TSD, TSS

Swapping the column position is left as an exercise.



__
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] Writing Faroes lettsers in text and plot ?

2012-08-04 Thread John Kane
Depends on your OS probably. 
I would just add a  Faroese keyboard to my Ubuntu setup and switch between my 
normal keyboard and Faoese as required.

John Kane
Kingston ON Canada


 -Original Message-
 From: klausflemlo...@mail.tele.dk
 Sent: Fri, 3 Aug 2012 10:08:48 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Writing Faroes lettsers in text and plot ?
 
 I need to write Faroese letters in plain tekst and in plots.
 
 How can I do this ?
 
 http://en.wikipedia.org/wiki/Faroese_language Faroese_language
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Writing-Faroes-lettsers-in-text-and-plot-tp4639074.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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
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] metafor- interpretation of moderators test for raw proportions

2012-08-04 Thread Michael Dewey

At 17:03 03/08/2012, cpanderson wrote:

Wolfgang,
Thanks for your quick response.  You are correct- indeed I had inadvertently
left out that i had set intercept = FALSE in rma.


Dear Christopher,
It does help if you paste in the exact code you used, see also below



Following your suggestions, I get the following results:

Test of Moderators (coefficient(s) 2,3):
QM(df = 2) = 0.2207, p-val = 0.8955

Model Results:

 estimate  se zvalpvalci.lb   ci.ub
intrcpt0.6498  0.0492  13.2160  .0001   0.5534  0.7462  ***
Complex0.0457  0.1007   0.4538  0.6500  -0.1517  0.2430
Dome   0.0244  0.1135   0.2148  0.8299  -0.1980  0.2468

This may be an even dumber question than my first one, but if you have time
I'd appreciate knowing how this works.  Originally I had tried the syntax
mods = ~ Technique.  I ended up getting the following error message:

Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve

if I supply the argument that mods =~ factor(Technique), I don't get the
singular matrix 'a' message.  But I don't understand why that should make a
difference, because dat$Technique is already an object of class factor:


Pasting in the exact code would help here and maybe also giving the 
output of traceback(). You might also consider pasting in the result 
of summary(dat) unless it is really huge.



class(dat$Technique)
[1] factor

Thanks again.

Christopher





--
View this message in context: 
http://r.789695.n4.nabble.com/metafor-interpretation-of-moderators-test-for-raw-proportions-tp4638972p4639057.html

Sent from the R help mailing list archive at Nabble.com.


Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

__
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] Partial Likelihood

2012-08-04 Thread doctoratza
Hello everyone,

i would like to ask if everyone knows how to perfom a glm partial likelihood
estimation in a time series whrere dependence exists.

lets say that i want to perform a logistic regression for binary data (0, 1)
with binary responses which a re the previous days.

for example:


logistic-glm(dat$Day~dat$Day1+dat$Day2, family=binomial(link=logit))

where dat$Day (0 or 1) is the current day  and dat$Day1 is one day before (0
or 1).

is it possible that R performs partial likelihood estimation automatically?


thank you in advance

Konstantinos Mammas




--
View this message in context: 
http://r.789695.n4.nabble.com/Partial-Likelihood-tp4639159.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 'x' must be numeric

2012-08-04 Thread Ivette
http://r.789695.n4.nabble.com/file/n4639158/elgas2.csv elgas2.csv 
http://r.789695.n4.nabble.com/file/n4639158/histogramselgas.R
histogramselgas.R 

Hello,

I want to plot 9 histograms, and I prepare the data for this operation with
the usual command,
sapply(x, is.numeric), then I get a confirmation that all data are numeric.
Strangely, when I want to plot the histograms I get the error message:
'x' must be numeric. My  'x' is already numeric and I have no idea what's
wrong.
Could somebody tell me where the error is? I attach my .csv data and my R
code.

Thank you.



--
View this message in context: 
http://r.789695.n4.nabble.com/Error-message-x-must-be-numeric-tp4639158.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] Questionnaire Analysis virtually without continuous Variables

2012-08-04 Thread Sacha Viquerat

Hello!
I am doing an analysis on a questionnaire of hunters taken in 4 
different districts of some mysterious foreign country. The aim of the 
study was to gather info on the factors that determine the hunting 
success of a peculiarly beautiful bird in that area. All variables are 
factors, i.e. they are variables such as Use of Guns - yes / no, Use 
of Dogs - yes / no and the likes. The response is upposed to be number 
of Birds caught, which was designed to be the only continuous variable. 
However, in reality the number of caught birds is between 0 and 1, 
sometimes hunters answered with 2. Unfortunately, it is not the 
questioner who is burdened with the analysis, but me. I am struggling to 
find an appropriate approach to the analysis. I don't really consider 
this as count data, since it would be very vulnerable to overinflation 
(and a steep decline for counts above 0). I can't really suggest 
binomial models either, since the lack of explanatory, continuous data 
renders such an approach quite vague. I also struggle with the random 
design of the survey (households nested within villages nested within 
districts). Adding to that, hunters don't even target the bird as their 
prime objective. The bird is essentially a by-catch, most often used for 
instant consumption on the hunting trip. I therefore doubt that any 
analysis makes more than a little sense, but I will not yet succumb to 
failure. Any ideas?


Thanks in advance!

PS: I just realized that this is not a question related to R but to 
statistics in general. Apologies for that!


__
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] how to assing unique ID in a table and do regression

2012-08-04 Thread Kristi Glover

Hi R- User
I have very big data set (5000 rows). I wanted to make classes based on a 
column of that table (that column has the data which is continuous .) After 
converting into different class, this class would be Unique ID. I want to run 
regression for each ID.
For example I have a data set 
 dput(dat)
structure(list(ID = c(0.1, 0.8, 0.1, 1.5, 1.1, 0.9, 1.8, 2.5, 
2, 2.5, 2.8, 3, 3.1, 3.2, 3.9, 1, 4, 4.7, 4.3, 4.9, 2.1, 2.4), 
S = c(4L, 7L, 9L, 10L, 10L, 8L, 8L, 8L, 17L, 18L, 13L, 13L, 
11L, 1L, 10L, 20L, 22L, 20L, 18L, 16L, 7L, 20L), en2 = c(-2.5767, 
-2.5767, -2.5767, -2.5767, -2.5767, -2.5767, -2.5767, -2.5347, 
-2.5347, -2.5347, -2.5347, -2.5347, -2.5347, -2.4939, -2.4939, 
-2.4939, -2.4939, -2.4939, -2.4939, -2.4939, -2.4543, -2.4543
), en3 = c(-1.1785, -0.6596, -0.6145, -0.6437, -0.6593, -0.7811, 
-1.1785, -1.1785, -1.1785, -0.6596, -0.6145, -0.6437, -0.6593, 
-1.1785, -0.1342, -0.2085, -0.4428, -0.5125, -0.8075, -1.1785, 
-1.1785, -0.1342), en4 = c(-1.4445, -1.3645, -1.1634, -0.7735, 
-0.6931, -1.1105, -1.4127, -1.5278, -1.4445, -1.3645, -1.1634, 
-0.7735, -0.6931, -1.0477, -0.8655, -0.1759, 0.1203, -0.2962, 
-0.4473, -1.0436, -0.9705, -0.8953), en5 = c(-0.4783, -0.3296, 
-0.2026, -0.3579, -0.5154, -0.5726, -0.6415, -0.3996, -0.4529, 
-0.5762, -0.561, -0.6891, -0.7408, -0.6287, -0.4337, -0.4586, 
-0.5249, -0.6086, -0.7076, -0.7114, -0.4952, 0.1091)), .Names = c(ID, 
S, en2, en3, en4, en5), class = data.frame, row.names = c(NA, 
-22L))

Here ID has continuous value, I want to make groups with value 0-1, 1-2, 2-3, 
3-4 from the column ID. 
and then. I wanted to run regression with S (dependent variable) and en2 
(independent variable); again regression of S and en3 , and so on.
After that, I wanted to have a table with r2 and p value.

would you help me how I can do it? I was trying it manually - but it took so 
much time. therefore I thought to write you for your help. 

Thanks for your help.
Kristi



  
[[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] Writing Faroes lettsers in text and plot ?

2012-08-04 Thread Ted Harding
Klaus: John Kane is right to point out that the procedure will
depend on your OS. It will also depend on what interface you use
for entering text into R.

All the letters you need for Faroese are present in the basic
iso-8859-1 Western European character set (also known as ISO-Latin1)
which should be available on just about any current operating system.
It is how you access the non-US/English alphabetical characters
which will depend on OS and interface.

In some cases (especially in Windows) there will be a drop-down
menu of available characters in which you point-and-click to
enter the character you want. Or your OS may allow you to set up
your keyboard configuration so that certain key-combinations give
special characters. Or you may use an editor program which itself
can have a special key setup.

The mail program in which I am typing this reply uses iso-8859-1
and has its own keyboard setup involving a system of digraphs.
Each digraph is initiated by pressing Control-D ([^D]), followed
by a sequence of two letters, so that [^D]AE gives Æ, for instance.

Thus, in addition to the usual A-Z, a-z:

[^D]A': Á[^D]D-: Ð[^D]I': Í[^D]O': Ó
[^D]U': Ú[^D]Y': Ý[^D]AE: Æ[^D]O/: Ø

with the corresponding digraphs for lower-case letters, such as
[^D]ae: æ etc.

I believe that may be enough for Faroese; however, if needed other
Nordic letters are available in iso-8859-1, such as þ ([^D]th),
Þ ([^D]TH), Ö ([^D]O], ö ([^D]o0, etc.

When using R (in Linux), as program editor I usually use vim, which
operates a similar digraph system (but with Control-K ([^K]) instead
of [^D]). One way of entering such characters directly into R is to
first enter them into a vim console window, and then (with mouse)
copy and paste into the R command line. However, the R command-line
window can have its own configuration as well. The choice is up to
you, in the context of your OS and resources.

It will probably be possible to give you direct and specific advice,
if you let us know what your system set-up is, and how you access R.

Hoping this helps,
Ted.

On 04-Aug-2012 13:25:07 John Kane wrote:
 Depends on your OS probably. 
 I would just add a  Faroese keyboard to my Ubuntu setup and switch
 between my normal keyboard and Faoese as required.
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: klausflemlo...@mail.tele.dk
 Sent: Fri, 3 Aug 2012 10:08:48 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Writing Faroes lettsers in text and plot ?
 
 I need to write Faroese letters in plain tekst and in plots.
 
 How can I do this ?
 
 http://en.wikipedia.org/wiki/Faroese_language Faroese_language
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Writing-Faroes-lettsers-in-text-and-plot-tp4639
 074.html
 Sent from the R help mailing list archive at Nabble.com.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 04-Aug-2012  Time: 15:41:39
This message was sent by XFMail

__
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] Error message 'x' must be numeric

2012-08-04 Thread Uwe Ligges

On 04.08.2012 12:18, Ivette wrote:

http://r.789695.n4.nabble.com/file/n4639158/elgas2.csv elgas2.csv
http://r.789695.n4.nabble.com/file/n4639158/histogramselgas.R
histogramselgas.R

Hello,

I want to plot 9 histograms, and I prepare the data for this operation with
the usual command,
sapply(x, is.numeric), then I get a confirmation that all data are numeric.
Strangely, when I want to plot the histograms I get the error message:
'x' must be numeric. My  'x' is already numeric and I have no idea what's
wrong.
Could somebody tell me where the error is? I attach my .csv data and my R
code.



You diverse x are data.frames rather than numeric vectors, just the 
columns of your data.frames are numeric.


Hence use, e.g., x1[,1] do access the first column of x1 etc.

Uwe Ligges




Thank you.



--
View this message in context: 
http://r.789695.n4.nabble.com/Error-message-x-must-be-numeric-tp4639158.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-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] how to assing unique ID in a table and do regression

2012-08-04 Thread Rui Barradas

Hello,

Try the following.


id.groups - with(dat, cut(ID, breaks=0:ceiling(max(ID
sp - split(dat, id.groups)
regressors - grep(en, names(dat))
models - lapply(sp, function(.df)
lapply(regressors, function(x) lm(.df[[S]] ~ .df[[x]])))

mod.summ - lapply(models, function(x) lapply(x, summary))
# First R2
mod.r2 - lapply(mod.summ, function(x) lapply(x, `[[`, r.squared))
mod.r2

# Now p-values
mod.coef - lapply(mod.summ, function(x) lapply(x, coef))
mod.pvalue - lapply(mod.coef,  function(x) lapply(x, `[`, , 4))
# p-values in matrix form, columns are 'en2', en3', etc
#lapply(mod.pvalue, function(x) do.call(cbind, x))

Hope this helps,

Rui Barradas

Em 04-08-2012 15:22, Kristi Glover escreveu:

Hi R- User
I have very big data set (5000 rows). I wanted to make classes based on a 
column of that table (that column has the data which is continuous .) After 
converting into different class, this class would be Unique ID. I want to run 
regression for each ID.
For example I have a data set

dput(dat)

structure(list(ID = c(0.1, 0.8, 0.1, 1.5, 1.1, 0.9, 1.8, 2.5,
2, 2.5, 2.8, 3, 3.1, 3.2, 3.9, 1, 4, 4.7, 4.3, 4.9, 2.1, 2.4),
 S = c(4L, 7L, 9L, 10L, 10L, 8L, 8L, 8L, 17L, 18L, 13L, 13L,
 11L, 1L, 10L, 20L, 22L, 20L, 18L, 16L, 7L, 20L), en2 = c(-2.5767,
 -2.5767, -2.5767, -2.5767, -2.5767, -2.5767, -2.5767, -2.5347,
 -2.5347, -2.5347, -2.5347, -2.5347, -2.5347, -2.4939, -2.4939,
 -2.4939, -2.4939, -2.4939, -2.4939, -2.4939, -2.4543, -2.4543
 ), en3 = c(-1.1785, -0.6596, -0.6145, -0.6437, -0.6593, -0.7811,
 -1.1785, -1.1785, -1.1785, -0.6596, -0.6145, -0.6437, -0.6593,
 -1.1785, -0.1342, -0.2085, -0.4428, -0.5125, -0.8075, -1.1785,
 -1.1785, -0.1342), en4 = c(-1.4445, -1.3645, -1.1634, -0.7735,
 -0.6931, -1.1105, -1.4127, -1.5278, -1.4445, -1.3645, -1.1634,
 -0.7735, -0.6931, -1.0477, -0.8655, -0.1759, 0.1203, -0.2962,
 -0.4473, -1.0436, -0.9705, -0.8953), en5 = c(-0.4783, -0.3296,
 -0.2026, -0.3579, -0.5154, -0.5726, -0.6415, -0.3996, -0.4529,
 -0.5762, -0.561, -0.6891, -0.7408, -0.6287, -0.4337, -0.4586,
 -0.5249, -0.6086, -0.7076, -0.7114, -0.4952, 0.1091)), .Names = c(ID,
S, en2, en3, en4, en5), class = data.frame, row.names = c(NA,
-22L))

Here ID has continuous value, I want to make groups with value 0-1, 1-2, 2-3, 
3-4 from the column ID.
and then. I wanted to run regression with S (dependent variable) and en2 
(independent variable); again regression of S and en3 , and so on.
After that, I wanted to have a table with r2 and p value.

would you help me how I can do it? I was trying it manually - but it took so 
much time. therefore I thought to write you for your help.

Thanks for your help.
Kristi




[[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.


Re: [R] Questionnaire Analysis virtually without continuous Variables

2012-08-04 Thread R. Michael Weylandt
On Sat, Aug 4, 2012 at 9:12 AM, Sacha Viquerat
dawa.ya.m...@googlemail.com wrote:
 Hello!
 I am doing an analysis on a questionnaire of hunters taken in 4 different
 districts of some mysterious foreign country. The aim of the study was to
 gather info on the factors that determine the hunting success of a
 peculiarly beautiful bird in that area. All variables are factors, i.e. they
 are variables such as Use of Guns - yes / no, Use of Dogs - yes / no and
 the likes. The response is upposed to be number of Birds caught, which was
 designed to be the only continuous variable. However, in reality the number
 of caught birds is between 0 and 1, sometimes hunters answered with 2.
 Unfortunately, it is not the questioner who is burdened with the analysis,
 but me. I am struggling to find an appropriate approach to the analysis. I
 don't really consider this as count data, since it would be very vulnerable
 to overinflation (and a steep decline for counts above 0). I can't really
 suggest binomial models either, since the lack of explanatory, continuous
 data renders such an approach quite vague. I also struggle with the random
 design of the survey (households nested within villages nested within
 districts). Adding to that, hunters don't even target the bird as their
 prime objective. The bird is essentially a by-catch, most often used for
 instant consumption on the hunting trip. I therefore doubt that any analysis
 makes more than a little sense, but I will not yet succumb to failure. Any
 ideas?

 Thanks in advance!


Hi Sacha,

This sounds a good deal like homework to me (some mysterious foreign
country) and this list has a no homework policy so unfortunately, I
don't think you'll be able to get much help here.

Best of luck with your analysis however!

Michael


 PS: I just realized that this is not a question related to R but to
 statistics in general. Apologies for that!

 __
 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.


Re: [R] metafor- interpretation of moderators test for raw proportions

2012-08-04 Thread Viechtbauer Wolfgang (STAT)
Just to follow up on what Michael wrote:

I cannot reproduce that error. For example, this all works as intended:

data(dat.bcg)

dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, 
append=TRUE)

rma(yi, vi, mods = ~ alloc, data=dat) ### 'alloc' automatically converted to a 
factor

dat$alloc - factor(dat$alloc) ### explicitly make 'alloc' a factor

rma(yi, vi, mods = ~ alloc, data=dat) ### works as before

rma(yi, vi, mods = ~ factor(alloc), data=dat) ### factor() not necessary, but 
works

If you can provide a reproducible example, I'll be glad to look into the issue.

Aside from that, the error you got occurs when the design matrix is not of full 
rank. For example:

X - model.matrix(~ factor(alloc) - 1, data=dat)
rma(yi, vi, mods = X, data=dat)

will fail, because the model now has an intercept plus the 3 dummy variables 
for the 3 levels (setting intercept=FALSE will make this work). It seems to me 
that this is what happened (since in your previous post, you showed that you 
coded the three levels of your factor manually). But this is something 
different than what you describe below, so I don't know for sure.

Best,

Wolfgang

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
cpanderson [christopher.p.ander...@healthpartners.com]
Sent: Friday, August 03, 2012 6:03 PM
To: r-help@r-project.org
Subject: Re: [R] metafor- interpretation of moderators test for raw 
proportions

Wolfgang,
Thanks for your quick response.  You are correct- indeed I had inadvertently
left out that i had set intercept = FALSE in rma.

Following your suggestions, I get the following results:

Test of Moderators (coefficient(s) 2,3):
QM(df = 2) = 0.2207, p-val = 0.8955

Model Results:

 estimate  se zvalpvalci.lb   ci.ub
intrcpt0.6498  0.0492  13.2160  .0001   0.5534  0.7462  ***
Complex0.0457  0.1007   0.4538  0.6500  -0.1517  0.2430
Dome   0.0244  0.1135   0.2148  0.8299  -0.1980  0.2468

This may be an even dumber question than my first one, but if you have time
I'd appreciate knowing how this works.  Originally I had tried the syntax
mods = ~ Technique.  I ended up getting the following error message:

Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve

if I supply the argument that mods =~ factor(Technique), I don't get the
singular matrix 'a' message.  But I don't understand why that should make a
difference, because dat$Technique is already an object of class factor:

class(dat$Technique)
[1] factor

Thanks again.

Christopher
__
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] Partial Likelihood

2012-08-04 Thread Bert Gunter
Sounds like generalized linear mixed modeling (glmm) to me. Try
posting to the r-sig-mixed-models list rather than here to increase
the likelihood of a useful response.

-- Bert

On Sat, Aug 4, 2012 at 3:55 AM, doctoratza mamma...@live.com wrote:
 Hello everyone,

 i would like to ask if everyone knows how to perfom a glm partial likelihood
 estimation in a time series whrere dependence exists.

 lets say that i want to perform a logistic regression for binary data (0, 1)
 with binary responses which a re the previous days.

 for example:


 logistic-glm(dat$Day~dat$Day1+dat$Day2, family=binomial(link=logit))

 where dat$Day (0 or 1) is the current day  and dat$Day1 is one day before (0
 or 1).

 is it possible that R performs partial likelihood estimation automatically?


 thank you in advance

 Konstantinos Mammas




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Partial-Likelihood-tp4639159.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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] DAtes

2012-08-04 Thread Trying To learn again
Hi all,

I´m trying to convert as a data frame (with format date) this copied
excel column of dates (exposed below), I have tried to save them in a txt
file

tfr-read.table(tfra.txt)
tfr-data.frame(tfr)

I have tried several things, as date, so on, but always error.

And it makes
Error en as.Date.default(tfr, %m/%d/%y) :

  do not know how to convert 'a' to class Date


Can anyone give me a clue or a gide to achieve this final result.












14/12/2000  15/12/2000  18/12/2000  19/12/2000  20/12/2000  21/12/2000
22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000  29/12/2000
01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001  08/01/2001
09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001  16/01/2001
17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001  24/01/2001
25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001  01/02/2001
02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001  09/02/2001
12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001  19/02/2001
20/02/2001  21/02/2001

[[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] DAtes

2012-08-04 Thread Rui Barradas
Hello,

Works with me:

x - scan(what = character, text = 14/12/2000  15/12/2000 18/12/2000  
19/12/2000  20/12/2000  21/12/2000
22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000 29/12/2000
01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001 08/01/2001
09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001 16/01/2001
17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001 24/01/2001
25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001 01/02/2001
02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001 09/02/2001
12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001 19/02/2001
20/02/2001  21/02/2001)

as.Date(x, format = %d/%m/%Y)

You've posted the error message but not the command. If it is what it 
seems to be, by looking at the error message, then you've passed the 
wrong format argument. There is NO month 14 (first date of all!)

Hope this helps,

Rui Barradas

Em 04-08-2012 17:09, Trying To learn again escreveu:
 Hi all,

 I´m trying to convert as a data frame (with format date) this copied
 excel column of dates (exposed below), I have tried to save them in a txt
 file

 tfr-read.table(tfra.txt)
 tfr-data.frame(tfr)

 I have tried several things, as date, so on, but always error.

 And it makes
 Error en as.Date.default(tfr, %m/%d/%y) :

do not know how to convert 'a' to class Date


 Can anyone give me a clue or a gide to achieve this final result.












 14/12/2000  15/12/2000  18/12/2000  19/12/2000  20/12/2000  21/12/2000
 22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000  29/12/2000
 01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001  08/01/2001
 09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001  16/01/2001
 17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001  24/01/2001
 25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001  01/02/2001
 02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001  09/02/2001
 12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001  19/02/2001
 20/02/2001  21/02/2001

   [[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.


[[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] Partial Likelihood

2012-08-04 Thread Joshua Wiley
In addition to Bert's suggestion of r sig mixed models (which I second), I 
would encourage you to create a more detailed example and explanation of what 
you hope to accomplish. Sounds a bit like an auto regressive structure, but 
more details would be good.

Cheers,

Josh

On Aug 4, 2012, at 9:34, Bert Gunter gunter.ber...@gene.com wrote:

 Sounds like generalized linear mixed modeling (glmm) to me. Try
 posting to the r-sig-mixed-models list rather than here to increase
 the likelihood of a useful response.
 
 -- Bert
 
 On Sat, Aug 4, 2012 at 3:55 AM, doctoratza mamma...@live.com wrote:
 Hello everyone,
 
 i would like to ask if everyone knows how to perfom a glm partial likelihood
 estimation in a time series whrere dependence exists.
 
 lets say that i want to perform a logistic regression for binary data (0, 1)
 with binary responses which a re the previous days.
 
 for example:
 
 
 logistic-glm(dat$Day~dat$Day1+dat$Day2, family=binomial(link=logit))
 
 where dat$Day (0 or 1) is the current day  and dat$Day1 is one day before (0
 or 1).
 
 is it possible that R performs partial likelihood estimation automatically?
 
 
 thank you in advance
 
 Konstantinos Mammas
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Partial-Likelihood-tp4639159.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.
 
 
 
 -- 
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
 
 __
 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.


Re: [R] Questionnaire Analysis virtually without continuous Variables

2012-08-04 Thread Joshua Wiley
 Hi Sacha,

You're right that this is not an R related question really (would be better 
somewhere like crossvalidated.com).

If basically everyone catches 0/1 birds, then I would consider dichotomizing:

Y - as.integer(caught = 1)

then check cross tabs to make sure there are no zero cells between predictors 
and outcome:

xtabs(~Y + dogs + guns, data=yourdata)

then use the glmer() function to model the nested random effects.

m - glmer(Y ~ dog + gun + (1 | household) + (1 | village) + (1 | district), 
data = yourdata, family=binomial)

summary(m)

Cheers,

Josh

On Aug 4, 2012, at 7:12, Sacha Viquerat dawa.ya.m...@googlemail.com wrote:

 Hello!
 I am doing an analysis on a questionnaire of hunters taken in 4 different 
 districts of some mysterious foreign country. The aim of the study was to 
 gather info on the factors that determine the hunting success of a peculiarly 
 beautiful bird in that area. All variables are factors, i.e. they are 
 variables such as Use of Guns - yes / no, Use of Dogs - yes / no and the 
 likes. The response is upposed to be number of Birds caught, which was 
 designed to be the only continuous variable. However, in reality the number 
 of caught birds is between 0 and 1, sometimes hunters answered with 2. 
 Unfortunately, it is not the questioner who is burdened with the analysis, 
 but me. I am struggling to find an appropriate approach to the analysis. I 
 don't really consider this as count data, since it would be very vulnerable 
 to overinflation (and a steep decline for counts above 0). I can't really 
 suggest binomial models either, since the lack of explanatory, continuous 
 data renders such an!
  approach quite vague. I also struggle with the random design of the survey 
(households nested within villages nested within districts). Adding to that, 
hunters don't even target the bird as their prime objective. The bird is 
essentially a by-catch, most often used for instant consumption on the hunting 
trip. I therefore doubt that any analysis makes more than a little sense, but I 
will not yet succumb to failure. Any ideas?
 
 Thanks in advance!
 
 PS: I just realized that this is not a question related to R but to 
 statistics in general. Apologies for that!
 
 __
 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.


Re: [R] DAtes

2012-08-04 Thread arun
Hi,
Try this:
tfr-read.table(text=
14/12/2000  15/12/2000  18/12/2000  19/12/2000  20/12/2000  21/12/2000
22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000  29/12/2000
01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001  08/01/2001
09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001  16/01/2001
17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001  24/01/2001
25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001  01/02/2001
02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001  09/02/2001
12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001  19/02/2001
20/02/2001  21/02/2001
,sep=,header=FALSE,fill=TRUE,stringsAsFactors=FALSE)
 as.Date(tfr$V1,format=%d/%m/%Y)
[1] 2000-12-14 2000-12-22 2001-01-01 2001-01-09 2001-01-17
[6] 2001-01-25 2001-02-02 2001-02-12 2001-02-20



A.K.



- Original Message -
From: Trying To learn again tryingtolearnag...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Saturday, August 4, 2012 12:09 PM
Subject: [R] DAtes

Hi all,

I´m trying to convert as a data frame (with format date) this copied
excel column of dates (exposed below), I have tried to save them in a txt
file

tfr-read.table(tfra.txt)
tfr-data.frame(tfr)

I have tried several things, as date, so on, but always error.

And it makes
Error en as.Date.default(tfr, %m/%d/%y) :

  do not know how to convert 'a' to class Date


Can anyone give me a clue or a gide to achieve this final result.












14/12/2000  15/12/2000  18/12/2000  19/12/2000  20/12/2000  21/12/2000
22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000  29/12/2000
01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001  08/01/2001
09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001  16/01/2001
17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001  24/01/2001
25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001  01/02/2001
02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001  09/02/2001
12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001  19/02/2001
20/02/2001  21/02/2001

    [[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.


Re: [R] DAtes

2012-08-04 Thread arun
HI,
I guess this will be more appropriate:

tfr-read.table(text=
14/12/2000  15/12/2000  18/12/2000  19/12/2000  20/12/2000  21/12/2000
22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000  29/12/2000
01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001  08/01/2001
09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001  16/01/2001
17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001  24/01/2001
25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001  01/02/2001
02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001  09/02/2001
12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001  19/02/2001
20/02/2001  21/02/2001
,sep=,header=FALSE,fill=TRUE,stringsAsFactors=FALSE)

tfr1-data.frame(dates=c(tfr[,1],tfr[,2],tfr[,3],tfr[,4],tfr[,5],tfr[,6]))
tfr2-tfr1[-c(27,36,45),]
 
head(data.frame(dates=as.Date(tfr2,format=%d/%m/%Y)))
  dates
1 2000-12-14
2 2000-12-22
3 2001-01-01
4 2001-01-09
5 2001-01-17
6 2001-01-25
# or you can do this:
 tfr1-as.vector(c(tfr[,1],tfr[,2],tfr[,3],tfr[,4],tfr[,5],tfr[,6]))
 tfr2-as.data.frame(as.Date(tfr1,format=%d/%m/%Y))
 colnames(tfr2)-dates
 head(tfr2)
   dates
1 2000-12-14
2 2000-12-22
3 2001-01-01
4 2001-01-09
5 2001-01-17
6 2001-01-25
A.K.



- Original Message -
From: Trying To learn again tryingtolearnag...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Saturday, August 4, 2012 12:09 PM
Subject: [R] DAtes

Hi all,

I´m trying to convert as a data frame (with format date) this copied
excel column of dates (exposed below), I have tried to save them in a txt
file

tfr-read.table(tfra.txt)
tfr-data.frame(tfr)

I have tried several things, as date, so on, but always error.

And it makes
Error en as.Date.default(tfr, %m/%d/%y) :

  do not know how to convert 'a' to class Date


Can anyone give me a clue or a gide to achieve this final result.












14/12/2000  15/12/2000  18/12/2000  19/12/2000  20/12/2000  21/12/2000
22/12/2000  25/12/2000  26/12/2000  27/12/2000  28/12/2000  29/12/2000
01/01/2001  02/01/2001  03/01/2001  04/01/2001  05/01/2001  08/01/2001
09/01/2001  10/01/2001  11/01/2001  12/01/2001  15/01/2001  16/01/2001
17/01/2001  18/01/2001  19/01/2001  22/01/2001  23/01/2001  24/01/2001
25/01/2001  26/01/2001  29/01/2001  30/01/2001  31/01/2001  01/02/2001
02/02/2001  05/02/2001  06/02/2001  07/02/2001  08/02/2001  09/02/2001
12/02/2001  13/02/2001  14/02/2001  15/02/2001  16/02/2001  19/02/2001
20/02/2001  21/02/2001

    [[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.


Re: [R] AFT model time-dependent with weibull distribution

2012-08-04 Thread hafida
Dear R-community, 
 
 I have tried to estimate an EXPONENTIEL accelerated failure time(AFT)
 power rule model  with time-independent . For that purpose, I have used
 the eha package. 
 Please, consider this example: 

  vi  Ti
1  265.79
2  26 1579.52
3  26 2323.70
4  28   68.85
5  28  426.07
6  28  110.29
7  28  108.29
8  28 1067.60
9  30   17.05
10 30   22.66
11 30   21.02
12 30  175.88
13 30  139.07
14 30  144.12
15 30   20.46
16 30   43.40
17 30  194.90
18 30   47.30
19 307.74
20 320.40
21 32   82.85
22 329.88
23 32   89.29
24 32  215.10
25 321.75
26 320.79
27 32   15.93
28 323.91
29 320.27
30 320.69
31 32  100.58
32 32   27.80
33 32   13.95
34 32   53.24
35 340.96
36 344.15
37 340.19
38 340.78
39 348.01
40 34   31.75
41 347.35
42 346.50
43 348.27
44 34   33.91
45 34   32.52
46 343.16
47 344.85
48 342.78
49 344.67
50 341.31
51 34   12.06
52 34   36.71
53 34   72.89
54 361.97
55 360.59
56 362.58
57 361.69
58 362.71
59 36   25.50
60 360.35
61 360.99
62 363.99
63 363.67
64 362.07
65 360.96
66 365.35
67 362.90
68 36   13.77
69 380.47
70 380.73
71 381.40
72 380.74
73 380.39
74 381.13
75 380.09
76 382.38
 aftexp-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
 dist=exponentiel)
Error in Surv(time, status) : Time variable is not numeric

 aftexp-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
 dist=exponentiel)
Error in Surv(Ti, status) : object 'status' not found
 status- rep(1, 76)
 status
 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1
[39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1

 cbind(dataexp, status)
   vi  Ti status
1  265.79  1
2  26 1579.52  1
3  26 2323.70  1
4  28   68.85  1
5  28  426.07  1
6  28  110.29  1
7  28  108.29  1
8  28 1067.60  1
9  30   17.05  1
10 30   22.66  1
11 30   21.02  1
12 30  175.88  1
13 30  139.07  1
14 30  144.12  1
15 30   20.46  1
16 30   43.40  1
17 30  194.90  1
18 30   47.30  1
19 307.74  1
20 320.40  1
21 32   82.85  1
22 329.88  1
23 32   89.29  1
24 32  215.10  1
25 321.75  1
26 320.79  1
27 32   15.93  1
28 323.91  1
29 320.27  1
30 320.69  1
31 32  100.58  1
32 32   27.80  1
33 32   13.95  1
34 32   53.24  1
35 340.96  1
36 344.15  1
37 340.19  1
38 340.78  1
39 348.01  1
40 34   31.75  1
41 347.35  1
42 346.50  1
43 348.27  1
44 34   33.91  1
45 34   32.52  1
46 343.16  1
47 344.85  1
48 342.78  1
49 344.67  1
50 341.31  1
51 34   12.06  1
52 34   36.71  1
53 34   72.89  1
54 361.97  1
55 360.59  1
56 362.58  1
57 361.69  1
58 362.71  1
59 36   25.50  1
60 360.35  1
61 360.99  1
62 363.99  1
63 363.67  1
64 362.07  1
65 360.96  1
66 365.35  1
67 362.90  1
68 36   13.77  1
69 380.47  1
70 380.73  1
71 381.40  1
72 380.74  1
73 380.39  1
74 381.13  1
75 380.09  1
76 382.38  1

 aftexp-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
 dist=exponentiel)
Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,  : 
  exponentiel is not an implemented distribution

 aftexp-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
 dist=exponentiel)
Error in Surv(time, status) : Time variable is not numeric
 pleas help me to find a solution to my problem




--
View this message in context: 
http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p4639174.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.


Re: [R] AFT model time-dependent with weibull distribution

2012-08-04 Thread David Winsemius


On Aug 4, 2012, at 10:45 AM, hafida wrote:


Dear R-community,


I have tried to estimate an EXPONENTIEL accelerated failure time(AFT)
power rule model  with time-independent . For that purpose, I have  
used

the eha package.
Please, consider this example:


 vi  Ti
1  265.79
2  26 1579.52
3  26 2323.70

snipped

74 381.13
75 380.09
76 382.38

aftexp-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
dist=exponentiel)

Error in Surv(time, status) : Time variable is not numeric


Your variables being given to the `Surv` function do not match those  
in you data object.





aftexp-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
dist=exponentiel)

Error in Surv(Ti, status) : object 'status' not found

status- rep(1, 76)
status
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  
1 1 1 1

1 1
[39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  
1 1 1 1

1 1


cbind(dataexp, status)

  vi  Ti status
1  265.79  1
2  26 1579.52  1


snipped

72 380.74  1
73 380.39  1
74 381.13  1
75 380.09  1
76 382.38  1


aftexp-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
dist=exponentiel)
Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id,  
control,  :

 exponentiel is not an implemented distribution


You are spelling 'exponential' incorrectly (in English anyway.)

Bon chance;
David.



aftexp-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
dist=exponentiel)

Error in Surv(time, status) : Time variable is not numeric

pleas help me to find a solution to my problem




--

David Winsemius, MD
Alameda, CA, USA

__
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] AFT model time-dependent with weibull distribution

2012-08-04 Thread Rui Barradas

Hello,

Vous êtes française?
It shows, in english it would be 'exponential', with an 'a'.

Worked with me, after reading the manual.


dataexp - read.table(text=
vi  Ti
1  265.79
2  26 1579.52
3  26 2323.70
4  28   68.85
[...]
73 380.39
74 381.13
75 380.09
76 382.38
, header=TRUE)

#  Better in a post to R-Help is the output of dput()
# It looks like the following line, without the assignment.
 dput(dataexp)
dataexp -
structure(list(vi = c(26L, 26L, 26L, 28L, 28L, 28L, 28L, 28L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 32L, 32L,
32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 36L, 36L, 36L, 36L, 36L, 36L, 36L,
36L, 36L, 36L, 36L, 36L, 36L, 36L, 36L, 38L, 38L, 38L, 38L, 38L,
38L, 38L, 38L), Ti = c(5.79, 1579.52, 2323.7, 68.85, 426.07,
110.29, 108.29, 1067.6, 17.05, 22.66, 21.02, 175.88, 139.07,
144.12, 20.46, 43.4, 194.9, 47.3, 7.74, 0.4, 82.85, 9.88, 89.29,
215.1, 1.75, 0.79, 15.93, 3.91, 0.27, 0.69, 100.58, 27.8, 13.95,
53.24, 0.96, 4.15, 0.19, 0.78, 8.01, 31.75, 7.35, 6.5, 8.27,
33.91, 32.52, 3.16, 4.85, 2.78, 4.67, 1.31, 12.06, 36.71, 72.89,
1.97, 0.59, 2.58, 1.69, 2.71, 25.5, 0.35, 0.99, 3.99, 3.67, 2.07,
0.96, 5.35, 2.9, 13.77, 0.47, 0.73, 1.4, 0.74, 0.39, 1.13, 0.09,
2.38), status = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), .Names = c(vi,
Ti, status), row.names = c(1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76), class = data.frame)

##Not run
#install.packages('eha')
library(eha)
library(survival)

dataexp$status - rep(1, 76)

aftexp - aftreg(Surv(Ti,status) ~ vi,  data=dataexp,
dist=weibull, shape=1)

str(aftexp)
summary(aftexp)
coef(aftexp)

The exponential can be seen as a special case of the weibull 
distribution with shape = 1.
And the help page of aftreg() says precisely to use the weibull with 
shape = 1 if we want an exponential.



Em 04-08-2012 18:45, hafida escreveu:

Dear R-community,

I have tried to estimate an EXPONENTIEL accelerated failure time(AFT)
power rule model  with time-independent . For that purpose, I have used
the eha package.
Please, consider this example:

   vi  Ti
1  265.79
2  26 1579.52
3  26 2323.70
4  28   68.85
5  28  426.07
6  28  110.29
7  28  108.29
8  28 1067.60
9  30   17.05
10 30   22.66
11 30   21.02
12 30  175.88
13 30  139.07
14 30  144.12
15 30   20.46
16 30   43.40
17 30  194.90
18 30   47.30
19 307.74
20 320.40
21 32   82.85
22 329.88
23 32   89.29
24 32  215.10
25 321.75
26 320.79
27 32   15.93
28 323.91
29 320.27
30 320.69
31 32  100.58
32 32   27.80
33 32   13.95
34 32   53.24
35 340.96
36 344.15
37 340.19
38 340.78
39 348.01
40 34   31.75
41 347.35
42 346.50
43 348.27
44 34   33.91
45 34   32.52
46 343.16
47 344.85
48 342.78
49 344.67
50 341.31
51 34   12.06
52 34   36.71
53 34   72.89
54 361.97
55 360.59
56 362.58
57 361.69
58 362.71
59 36   25.50
60 360.35
61 360.99
62 363.99
63 363.67
64 362.07
65 360.96
66 365.35
67 362.90
68 36   13.77
69 380.47
70 380.73
71 381.40
72 380.74
73 380.39
74 381.13
75 380.09
76 382.38

aftexp-aftreg(Surv(time,status) ~ vi,  data=data.frame(dataexp),
dist=exponentiel)

Error in Surv(time, status) : Time variable is not numeric


aftexp-aftreg(Surv(Ti,status) ~ vi,  data=data.frame(dataexp),
dist=exponentiel)

Error in Surv(Ti, status) : object 'status' not found

status- rep(1, 76)
status

  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1
[39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1


cbind(dataexp, status)

vi  Ti status
1  265.79  1
2  26 1579.52  1
3  26 2323.70  1
4  28   68.85  1
5  28  426.07  1
6  28  110.29  1
7  28  108.29  1
8  28 1067.60  1
9  30   17.05  1
10 30   22.66  1
11 30   21.02  1
12 30  175.88  1
13 30  139.07  1
14 30  144.12  1
15 30   20.46  1
16 30   43.40  1
17 30  194.90  1
18 30   47.30  1
19 307.74  1
20 320.40  1
21 32   82.85  1
22 329.88  1
23 32   89.29  1
24 32  215.10  1
25 321.75  1
26 320.79  1
27 32   15.93  1
28 323.91  1
29 320.27  1
30 320.69  1
31 32  100.58  1
32 32   27.80  1
33 32   13.95  1
34 32   53.24  1
35 340.96  1
36 344.15  1
37 340.19  1
38 

Re: [R] Partial Likelihood

2012-08-04 Thread Ben Bolker
Joshua Wiley jwiley.psych at gmail.com writes:

 
 In addition to Bert's suggestion of r sig mixed models 
 (which I second), I would encourage you to create a
 more detailed example and explanation of what you hope to accomplish.
  Sounds a bit like an auto regressive
 structure, but more details would be good.
 
 Cheers,
 
 Josh
 
 On Aug 4, 2012, at 9:34, Bert Gunter gunter.berton at gene.com wrote:
 
  Sounds like generalized linear mixed modeling (glmm) to me. Try
  posting to the r-sig-mixed-models list rather than here to increase
  the likelihood of a useful response.
  
  -- Bert
  
  On Sat, Aug 4, 2012 at 3:55 AM, doctoratza mammas_k at live.com wrote:
  Hello everyone,
  
  i would like to ask if everyone knows how to perfom a glm partial 
  likelihood
  estimation in a time series whrere dependence exists.
  
  lets say that i want to perform a logistic regression for binary data (0, 
  1)
  with binary responses which a re the previous days.
  
  for example:
  
  
  logistic-glm(dat$Day~dat$Day1+dat$Day2, family=binomial(link=logit))
  
  where dat$Day (0 or 1) is the current day  and dat$Day1 is one day before 
  (0
  or 1).

 ... and presumably Day2 is 2 days before?

  
  is it possible that R performs partial likelihood estimation automatically?
  
  

  Since it's plausible in this case that the responses are all observed without
error,
I don't necessarily see why you need GLMMs, or anything beyond a regular GLM
fit to do this ... you just need up to set the lagged variables correctly.

As I interpret this question,

  dat - data.frame(Day=c(Day,rep(NA,2)),Day1=c(NA,Day,NA),Day2=c(NA,NA,Day))
  glm(Day~Day1+Day2,na.action=na.exclude,data=dat,family=binomial)

should work just fine (na.action=na.exclude isn't really necessary -- the
default behavior is to omit NAs -- but this way if you do something like
predictions it will automatically give you NA values for the beginning and
end of the series).

  Autoregression is only hard when the process is observed with error ...

__
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] Getting unknown error trying to plot spatial data

2012-08-04 Thread mjkatsaros
Hi there! I'm following an awesome guide to working with spatial data
(http://www.frankdavenport.com/blog/2012/6/19/notes-from-a-recent-spatial-r-class-i-gave.html)
and am running into an error that I can't figure out how to fix.

Disclaimer: I am very much an R n00b

Here is the r script I am running:
https://dl.dropbox.com/u/28231177/This%20Should%20Work.R

data: https://dl.dropbox.com/u/28231177/my_data.csv

shapefile: https://dl.dropbox.com/u/28231177/sfzipcodes.zip

I am getting two errors:

 pds - fortify(sf_map)
*Using OBJECTID to define regions.*
 pds$OBJECTID - as.integer(pds$OBJECTID)
*Error in `$-.data.frame`(`*tmp*`, OBJECTID, value = integer(0)) : 
  replacement has 0 rows, data has 16249*
   
 
 ## Make the map
 
 p1 - ggplot(my_data, aes(map_id = zip))
 p1 - p1 + geom_map(aes(fill=vol, map_id = zip), map = pds)
 p1 - p1 + expand_limits(x = pds$lon, y = pds$lat) + coord_equal()
 p1 + xlab(Basic Map with Default Elements)
*Error in unit(x, default.units) : 'x' and 'units' must have length  0*

Anybody have any idea what is happening here or how to resolve this?

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-unknown-error-trying-to-plot-spatial-data-tp4639179.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] how to coerce the result of sweep to be an array if result of FUN is a string?

2012-08-04 Thread Peter Young
Hi,

 

I would like to use sweep to sweep out proportions and confidence intervals 
for an array, however when I supply a function which returns a string 
(containing something like 9% (3-18%)) I get back a list instead of an array, 
here is a simplified example:

 

# example showing that sweep does not return an array with same dimensions as 
STATS as advertised

 

string.fun - function(a, b) {

paste(a, -, b, sep=)

}

num.fun - function(a, b) {

a+b/100

}

m - array(seq(1:24), dim = c(2,3,4))

stat - array(seq(1:12), dim = c(3,4))

 

string.ans - sweep(m, c(2,3), stat, string.fun)

dim(string.ans)

length(string.ans)

num.ans - sweep(m, c(2,3), stat, num.fun)

dim(num.ans)

 

Although the contents are correct, strings.ans is a list while num.ans is an 
array. Help(sweep) says that the result of sweep should have the same 
dimensions as x, however when the result of the function is a string this is 
not the case.  How can I coerce the result of the function to cause sweep to 
return an array as advertised?

 

thanks,

Peter

 

Peter Young, MPH

Surveillance Epidemiologist

CDC Mozambique

 


[[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] AFT model time-dependent with weibull distribution

2012-08-04 Thread hafida
thanks a lot 
sorry for the mistake that i do in exponential, i am francophone

and for the programme if we want to apply the power rule  condition we use 
log(vi).
it works  thank yo



--
View this message in context: 
http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p4639184.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.


Re: [R] Partial Likelihood

2012-08-04 Thread doctoratza
Thank you for your comment. I suspected that a model with well defined
predictors should work fine with a glm procedure.

Thanks again

K



--
View this message in context: 
http://r.789695.n4.nabble.com/Partial-Likelihood-tp4639159p4639185.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.


Re: [R] how to coerce the result of sweep to be an array if result of FUN is a string?

2012-08-04 Thread Rui Barradas

Hello,

You can coerce the result to the input shape by assigning the dim 
attribute by hand.


string.ans - sweep(m, c(2,3), stat, string.fun)
dim(string.ans) - dim(m)
string.ans

Or put this in a function.

# An abbreviation and the complete function name
sweep.ch - sweep.character -
function(x, MARGIN, STATS, FUN=-, check.margin=TRUE, ...){
result - sweep(x, MARGIN, STATS, FUN, check.margin, ...)
dim(result) - dim(x)
result
}

string.ans2 - sweep.ch(m, c(2,3), stat, string.fun)
string.ans2


Hope this helps,

Rui Barradas

Em 04-08-2012 20:35, Peter Young escreveu:

Hi,

  


I would like to use sweep to sweep out proportions and confidence intervals for an 
array, however when I supply a function which returns a string (containing something like 9% 
(3-18%)) I get back a list instead of an array, here is a simplified example:

  


# example showing that sweep does not return an array with same dimensions as 
STATS as advertised

  


string.fun - function(a, b) {

 paste(a, -, b, sep=)

}

num.fun - function(a, b) {

 a+b/100

}

m - array(seq(1:24), dim = c(2,3,4))

stat - array(seq(1:12), dim = c(3,4))

  


string.ans - sweep(m, c(2,3), stat, string.fun)

dim(string.ans)

length(string.ans)

num.ans - sweep(m, c(2,3), stat, num.fun)

dim(num.ans)

  


Although the contents are correct, strings.ans is a list while num.ans is an 
array. Help(sweep) says that the result of sweep should have the same 
dimensions as x, however when the result of the function is a string this is 
not the case.  How can I coerce the result of the function to cause sweep to 
return an array as advertised?

  


thanks,

Peter

  


Peter Young, MPH

Surveillance Epidemiologist

CDC Mozambique

  



[[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.


Re: [R] Questionnaire Analysis virtually without continuous Variables

2012-08-04 Thread Joshua Wiley
You may be able to get around zero cells using a an MCMC approach such as with 
MCMCglmm.

On Aug 4, 2012, at 15:30, Sacha Viquerat dawa.ya.m...@googlemail.com wrote:

 On 08/04/2012 07:57 PM, Joshua Wiley wrote:
  Hi Sacha,
 
 You're right that this is not an R related question really (would be better 
 somewhere like crossvalidated.com).
 
 If basically everyone catches 0/1 birds, then I would consider dichotomizing:
 
 Y - as.integer(caught = 1)
 
 then check cross tabs to make sure there are no zero cells between 
 predictors and outcome:
 
 xtabs(~Y + dogs + guns, data=yourdata)
 
 then use the glmer() function to model the nested random effects.
 
 m - glmer(Y ~ dog + gun + (1 | household) + (1 | village) + (1 | district), 
 data = yourdata, family=binomial)
 
 summary(m)
 
 Cheers,
 
 Josh
 
 On Aug 4, 2012, at 7:12, Sacha Viquerat dawa.ya.m...@googlemail.com wrote:
 
 Hello!
 I am doing an analysis on a questionnaire of hunters taken in 4 different 
 districts of some mysterious foreign country. The aim of the study was to 
 gather info on the factors that determine the hunting success of a 
 peculiarly beautiful bird in that area. All variables are factors, i.e. 
 they are variables such as Use of Guns - yes / no, Use of Dogs - yes / 
 no and the likes. The response is upposed to be number of Birds caught, 
 which was designed to be the only continuous variable. However, in reality 
 the number of caught birds is between 0 and 1, sometimes hunters answered 
 with 2. Unfortunately, it is not the questioner who is burdened with the 
 analysis, but me. I am struggling to find an appropriate approach to the 
 analysis. I don't really consider this as count data, since it would be 
 very vulnerable to overinflation (and a steep decline for counts above 0). 
 I can't really suggest binomial models either, since the lack of 
 explanatory, continuous data renders such !
 an approach quite vague. I also struggle with the random design of the survey 
(households nested within villages nested within districts). Adding to that, 
hunters don't even target the bird as their prime objective. The bird is 
essentially a by-catch, most often used for instant consumption on the hunting 
trip. I therefore doubt that any analysis makes more than a little sense, but I 
will not yet succumb to failure. Any ideas?
 
 Thanks in advance!
 
 PS: I just realized that this is not a question related to R but to 
 statistics in general. Apologies for that!
 
 __
 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.
 I did exactly what you proposed already (since the binomial model seemed 
 obvious to me), however, of course there are zero cells. I was thinking 
 someone more accustomed to doing questionnaire analysis could unveil some 
 mysterious approach common to sociologists but occluded from the naturalists 
 eyes (hardened after years of dealing with exact science ;)
 I think I will expand the binomial approach and just try to find fancy 
 graphics that make up for the low value of the actual results (maybe with 
 colours). :D
 Thank you for the reply (do they really give such tasks for homework these 
 days? These kids must be awesome statisticians!)
 

__
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] ggplot2 boxplot help

2012-08-04 Thread apadr007
Hello, 

I have a data set that looks like this: 

   name  G-ID test_id g-id g
1 00077464 C_068131 C_068131 OC_068131-
2 00051728 C_044461 C_044461 OC_044461-
3 00058738 C_050343 C_050343 OC_050343-
4 00059239 C_050649 C_050649 OC_050649-
5 1761 C_000909 C_000909 OC_000909-
6 5119 C_002752 C_002752 OC_002752-
 locssample_1 sample_2 value_1  value_2
1 37316550-37317847   N  C   1.9268400 36.77590
2 27058468-27060176   N  C   0.1817890  5.58835
3 4761739-4763268N  C0.2309000 
7.54035
4  14565311-14567393   N C  0.0294559 
1.50886
5  38670994-38675694   N  C 0.4678610
14.75560
6   48362804-48380794   N C 10.7258000
92.13150



In this dataset, sample_1 corresponds to value_1 and sample_2 corresponds to
value_2. How can I graph this in ggplot2's boxplot function? I am not quite
sure how to tell R that sample_1 and sample_2 columns correspond to value_1
and value_2 using ggplot2. 

Can anyone shed some light on this?

Thanks. 



--
View this message in context: 
http://r.789695.n4.nabble.com/ggplot2-boxplot-help-tp4639187.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.


Re: [R] evaluate sum of sum

2012-08-04 Thread hafida
Hi
can any body please help me to programme this formula:
a[j]= E[j]-sum from l=i  to i-1 (exp{(B0 B1*row matrix*) (z[l]*column
matrix*) } x[l])  /  sum from l=i to n

it s complicate for me ; hope you can help me 
thank you a lot



--
View this message in context: 
http://r.789695.n4.nabble.com/evaluate-sum-of-sum-tp898262p4639191.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.


Re: [R] sapply and matrix command

2012-08-04 Thread alijk1989 [via R]


Thanks again for the help looks like this will be useful for what I'm doing.
Is there any way to use combn to return combinations of values with
themselves:

e.g.

combn(1:3,2)

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]111   2 2 3
[2,]1   232 3 3



___
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/sapply-and-matrix-command-tp4637769p4639190.html

To unsubscribe from sapply and matrix command, visit 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4637769code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzNzc2OXwtNzg0MjM1NTA4
[[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] sapply and matrix command

2012-08-04 Thread R. Michael Weylandt michael.weyla...@gmail.com
Take a look at ?expand.grid

Michael

On Aug 4, 2012, at 5:03 PM, alijk1989 [via R] 
ml-node+s789695n463919...@n4.nabble.com wrote:

 
 
 Thanks again for the help looks like this will be useful for what I'm doing.
 Is there any way to use combn to return combinations of values with
 themselves:
 
 e.g.
 
 combn(1:3,2)
 
 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]111   2 2 3
 [2,]1   232 3 3
 
 
 
 ___
 If you reply to this email, your message will be added to the discussion 
 below:
 http://r.789695.n4.nabble.com/sapply-and-matrix-command-tp4637769p4639190.html
 
 To unsubscribe from sapply and matrix command, visit 
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4637769code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzNzc2OXwtNzg0MjM1NTA4
[[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.


Re: [R] lme4 / HLM question

2012-08-04 Thread Ben Bolker
Jeff r at jp.pair.com writes:

  I'm hoping that this is a relatively easy question for someone
  familiar with the lme4 package.  I'm accustomed to using HLM
  software and writing a simple 2 level [null] equation like this:

L1 - Yij = b0 +  e
L2 - b0 = B00 + u0

The following command in R provides results that are identical to
the HLM program.

results - lmer( Y ~ 1 |id , PanelData4)

I can't seem to find any examples on-line nor in the help about
how to write the lmer4 formula that contains two predictor
variables at level 1 with fixed slopes.

L1 - Yij = b0 + b1(x) + b2(z) + e
L2 - b0 = B00 + u0
   b1 =  B10
b2 = B20

  In general you'd probably be better off asking this question
at r-sig-mixed-mod...@r-project.org ... but it's very easy to
put fixed effects into a model --

  lmer (Y ~ x + z + (1|id), PanelData4)

 or in lme (nlme package):

  lme ( Y~ x + z, random = ~ 1|id, PanelData4)

  Neither lmer nor lme need to be told explicitly which level
the fixed effects vary at (the data are always provided in 
long form).

Ben Bolker

__
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] how to put barchart and line chart in the same plot in ggplot2

2012-08-04 Thread xin wei
dear userR:
I am trying to plot two dependent variables in the same plot in ggplot2.
because these two variables have very different magnitude, I have to use a
second Y axis. I hope one variable to be line and the other to be barchart.
The x axis is continuous. Yet since I have to make barchart, I guess I have
to treat it as discrete or categorical.
I have been google searching for the whole afternoon but do not have any
clue. 
Can anyone give me a direction (not have to be a complete answer...)?

many thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-put-barchart-and-line-chart-in-the-same-plot-in-ggplot2-tp4639194.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] ptproc package

2012-08-04 Thread amirzadeh
Dear all
I came across  ptproc package on following website:
http://www.biostat.jhsph.edu/~rpeng/software/index.html

 Actually I downloaded it on the contributors website and tried to install
it manual but R wont unzip it. It is not available on CRAN project.
I use R 2.15.1 and windows vista on my computer. Any help would be
appreciated.
Thanks.
Amir Zadeh.



--
View this message in context: 
http://r.789695.n4.nabble.com/ptproc-package-tp4639196.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] Possible bug with MCMCpack metropolis sampler

2012-08-04 Thread dcervone
Hi,

I'm having issues with what I believe is a bug in the MCMCpack's
MCMCmetrop1R function. I have code that basically looks like this:

posterior.sampler - function(data, prior.mu){
   log.posterior - function(theta) log.likelihood(data, theta) +
log.prior(prior.mu, theta)
   post.samples - MCMCmetrop1R(log.posterior, theta.init=prior.mu,
burnin=100, mcmc=1000, thin=40, tune=1, verbose=0, logfun=T,
optim.method=BFGS)
   return(post.samples)
}

x - c(1,1,1)
posterior.sampler(mydata, x)

After calling posterior.sampler, the value for x is different from what I
started with. Perhaps even more interesting, is that if I create a copy of
x, say x2, before running posterior.sampler, x2 is modified as well. And I
have checked that calling log.posterior is not what alters the value of x,
so that leads me to believe it must be MCMCmetrop1R. Also, if I use
theta.init = c(1,1,1) instead of theta.init = prior.mu then x is not
altered. All of the behavior I described persists if I just run the
MCMCmetorp1R call (with the variables renamed of course) on its own and not
as part of my posterior.sampler function.

Any idea what's going on?

Thanks,
Dan Cervone



--
View this message in context: 
http://r.789695.n4.nabble.com/Possible-bug-with-MCMCpack-metropolis-sampler-tp4639199.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] Package to remove collinear variables

2012-08-04 Thread Roberto
Hi,
I need to remove collinear variables to my Near-Infrared table of spectra.

What package can I use? 

Something simple, because I am a novice about statistic.

Thank you.

Best regards,
Roberto



--
View this message in context: 
http://r.789695.n4.nabble.com/Package-to-remove-collinear-variables-tp4639200.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.