Hanze Zhang | 18 Sep 08:22 2014
Picon

R2WINBUGS Error message

Hi, guys,

I am a new user for package R2winbugs. When I run the code a=bugs(...), an
error message always comes out, see below:

Error in file(con, "wb") : cannot open the connection
In addition: Warning messages:
1: In file.create(to[okay]) :
  cannot create file 'c:/Program
Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission denied'
2: In file(con, "wb") :
  cannot open file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry.odc':
Permission denied

How to solve this issue?

Thanks a lot!

	[[alternative HTML version deleted]]

Daniela Droguett | 17 Sep 22:45 2014
Picon

svyby and vcov function problem (Survey Package)

Hi all,

I would like to apply the vcov function from the survey package for the
variables api00 and api99 grouped by the stype variable which can assume H,
M and E categories (see below)

I have tried svyby but as far as I know covariant matrices don't work with
this function
​
In the code example (survey package manual) they apply the as.svrepdesign
and then svyby with svymean function but I need svyby with svytotal without
as.svrepdesign.

data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
rclus1<-as.svrepdesign(dclus1)
mns<-svyby(~api00, ~stype, rclus1, svymean,covmat=TRUE)
vcov(mns)

how to mix the different stypes to obtain terms like:

api00:H api00:H
api00:H api00:M
api00:H api00:E
api00:H api99:H
api00:H api99:M
api00:H api99:E

api00:E api00:E
api00:E api00:M
(Continue reading)

Michael Friendly | 17 Sep 22:34 2014
Picon

plots on log="y" scale with smooths

In the following example, I am trying to plot a response on a log scale, 
and add one or more smoothed
curves, e.g., lowess and abline.  In base graphics, I'd like to do this 
using log="y", so that the Y axis is
spaced on the log scale, but labeled as the actual response values. 
Using ggplot2, I'm using
scale_y_log10 to achieve the same purpose.  However, my attempts to add 
the smooths differ
considerably, so I must be missing something.

Here's the data I'm working with for one example:

data("CodParasites", package = "countreg")
## omit NAs in response & predictor
CodParasites <- subset(CodParasites, !(is.na(intensity) | is.na(length)))
## plot only positive values of intensity
CPpos <- subset(CodParasites, intensity>0)

Here's the base graphics plot.  The abline() is clearly wrong and the 
lowess smooth looks too low.
How does one meld plots using log="y" with such additional plot 
annotations ?

plot(jitter(intensity) ~ length, data = CPpos, log = "y")
with(CPpos, lines(lowess(length, log(intensity)), col="red", lwd=2) )
abline(lm(log(intensity) ~ length, data=CPpos))

Here's an attempt at a ggplot2 version, that actually looks more 
reasonable, but I'm not sure that it
is correct:
(Continue reading)

Donia Smaali Bouhlila | 17 Sep 20:13 2014
Picon

Pseudo R squared for quantile regression with replicates

Hi,

I am running quantile regressions with replicates, but I don't know how 
to calculate the Pseudo R squared  for quantile regression with 
replicates. I have used the following commands:

rho <- function(u,tau=.5)u*(tau - (u < 0))
	V <- sum(rho(fit$resid, fit$tau))

where fit is my objective function

However, I get the following error message:

  Error in fit$resid : $ operator is invalid for atomic vectors

Any suggestion please
--

-- 
Dr. Donia Smaali Bouhlila
Associate-Professor
Department of Economics
Faculté des Sciences Economiques et de Gestion de Tunis

______________________________________________
R-help <at> 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.
Sarah Signor | 17 Sep 21:54 2014
Picon

package "ape" read.dna diploid input data

I am fundamentally not understanding something about how this is set up,
but after a few hours of googling I am going to ask and I apologize if its
quite basic. I have sanger data that I am reading into ape with read.dna.

x<-read.dna("/Volumes/Storage/file.phy", format = "interleaved")

It has IUPAC codes in the data, which represent polymorphisms in a diploid
system. It is consistently read as haploid data, both in ape and when I
convert it for adegenet. What are you supposed to do to make the data read
as diploid? You can't just include duplicates of the sequences, it doesn't
work. I've tried it with sequential alignments and .fasta files.

Thanks

	[[alternative HTML version deleted]]

Giovanni Petris | 17 Sep 20:25 2014
Picon

Generating unordered, with replacement, samples


Hello,

I am trying to interface in my teaching some elementary probability with Monte Carlo ideas. In sampling
from a finite population, the number of distinct samples of size 'k' from a population of size 'n' , when
individuals are selected with replacement and the selection order does not matter, is choose(n + k -1, k).
Does anyone have a suggestion about how to simulate (uniformly!) one of these possible samples? In a Monte
Carlo framework I would like to do it repeatedly, so efficiency is of some relevance.

Thank you in advance!

Best,
Giovanni

Giovanni Petris
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

Mohan Radhakrishnan | 17 Sep 20:04 2014
Picon

Re: Training a model using glm

Hi Dennis,

                     Why is there that warning ? I think my syntax is
right. Isn't it not? So the warning can be ignored ?

Thanks,
Mohan

On Wed, Sep 17, 2014 at 9:48 PM, Dennis Murphy <djmuser <at> gmail.com> wrote:

> No reproducible example (i.e., no data) supplied, but the following
> should work in general, so I'm presuming this maps to the caret
> package as well. Thoroughly untested.
>
> library(caret)    # something you failed to mention
>
> ...
> modelFit <- train(diagnosis ~ ., data = training1)    # presumably a
> logistic regression
> confusionMatrix(test1$diagnosis, predict(modelFit, newdata = test1,
> type = "response"))
>
> For GLMs, there are several types of possible predictions. The default
> is 'link', which associates with the linear predictor. caret may have
> a different syntax so you should check its help pages re the supported
> predict methods.
>
> Hint: If a function takes a data = argument, you don't need to specify
> the variables as components of the data frame - the variable names are
> sufficient. You should also do some reading to understand why the
(Continue reading)

ce | 17 Sep 15:51 2014
Picon

ANN ARIMA or ANN ES Examples ?


Hello,

I am looking for ANN ARIMA or ANN ES  ( Artificial Neural Networks Hybrid with  ARIMA or Exponential Smoothing
) R examples or packages ?
as referenced in http://cs.uni-muenster.de/Professoren/Lippe/diplomarbeiten/html/eisenbach/Untersuchte%20Artikel/Zhan03.pdf

regards

eliza botto | 17 Sep 14:28 2014
Picon

column names to row names

Dear useRs,
I have a data frame "y"  starting from 1961 to 2010 in the following manner (where A,B,C ......, I are station
names and the values uder these are "discharge" values.)
> dput(y)
structure(c(1961, 1961, 1961, 1961, 1, 1, 1, 1, 1, 2, 3, 4, 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), .Dim = c(4L, 12L), .Dimnames =
list(NULL, c("year", "month", "day", "A", "B", "C", "D", "E", "F", "G", "H", "I")))

I want it to be in the following manner "E" where the stations names are in a seperate column and all discharge
values are in one column.
> dput(E)

structure(list(year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "1961", class = "factor"),     month =
c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,     2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,     4), day = c(1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,     1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,     4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L), discharge = structure(c(1L,     12L, 23L, 31L, 32L, 33L, 34L, 35L, 36L, 2L, 3L, 4L, 5L, 6L,    
7L, 8L, 9L, 10L, 11L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,     20L, 21L, 22L, 24L, 25L, 26L, 27L, 28L, 29L, 30L),
.Label = c("1",     "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",     "
 2", "20", "21", "22", "23", "24", "25", "26", "27", "28",     "29", "3", "30", "31", "32", "33", "34", "35",
"36", "4",     "5", "6", "7", "8", "9"), class = "factor"), station = c("A",    !
  "A", "A", "A", "B", "B", "B", "B", "C", "C", "C", "C", "D",     "D", "D", "D", "E", "E", "E", "E", "F", "F", "F",
"F", "G",     "G", "G", "G", "H", "H", "H", "H", "I", "I", "I", "I")), .Names = c("year", "month", "day",
"discharge", "station"), row.names = c(NA, 36L), class = "data.frame")

I hope I followed all the instructions given to be by some fellows.
Thankyou very much in advance.
Eliza
 		 	   		  
	[[alternative HTML version deleted]]
(Continue reading)

Benjamin Tyner | 17 Sep 13:04 2014
Picon

<NA> from cut.Date

Hello,

I'm wondering if this is expected?

    > cut(structure(11111, class="Date"), structure(c(11100,11111),
class="Date"))
    [1] <NA>
    Levels: 2000-05-23

The help page says that "for ‘"Date"’ objects, only ‘"day"’, ‘"week"’,
‘"month"’, ‘"quarter"’ and ‘"year"’ are allowed" [for the 'breaks'
argument]. Though I am not sure whether this statement is only
applicable in the context of the previous sentence about interval
specification (i.e., a roundabout way of saying that ‘"sec"’, ‘"min"’,
‘"hour"’, and ‘"DSTday"’ are not allowed for 'Date' objects), or whether
it also means that a vector of cut points (as in my example) is likewise
not allowed? If the latter, then perhaps the function out to error out
rather than return <NA> in this case?

Regards
Ben

Hello,

I'm wondering if this is expected?

    > cut(structure(11111, class="Date"), structure(c(11100,11111),
class="Date"))
(Continue reading)

Thiago V. dos Santos | 17 Sep 10:53 2014
Picon

Control color palette and legend in filled.contour

Dear all,

I am having some difficulties trying to control color palette and legend of a filled.countour plot. 

Basically, I am plotting volumetric soil moisture which ranges from 0 to 1 (although the data excerpt I'm
providing here ranges from 0 to 0.4, my complete dataset ranges from 0 to 1). Low values mean dry soil and
higher values denote wet soil.

Instead of the default color palette, I would like to set a 'red to blue' palette with legend ranging from 0
(red) to 1 (blue). My final goal is to achive a color palette and legend similar to this figure:
https://imageshack.com/i/exmVz5QSp. 

A sample of my data (as well as an attemptive plot) can be reproduced with this code:

-------------------------------------------------------------------------------------------------

library(repmis) # reads text data directly from dropbox - no need to download any file

# read data
url <- 'https://dl.dropboxusercontent.com/u/27700634/precip.txt'
tmp <- repmis::source_data(url, sep = '', header = TRUE)

# convert julian day to date
date <- as.Date(tmp$julian, origin='2011-12-31')
data <- cbind(date, tmp)
head(data)

# define vector with depth of soil layers
depths <- c(0.05,0.10,0.20,0.30,
                 0.40,0.60,0.80,1.00,
(Continue reading)


Gmane