Re: [R] Output of arima

2018-11-14 Thread Ashim Kapoor
Dear Eric,

Many thanks for your reply.

Best Regards,
Ashim

On Wed, Nov 14, 2018 at 4:05 PM Eric Berger  wrote:

> Hi Ashim,
> Per the help page for arima(), it fits an ARIMA model to the specified
> time series - but the caller has to specify the order - i.e. (p,d,q) - of
> the model.
> The default order is (0,0,0) (per the help page). Hence your two calls are
> different. The first call is equivalent to order=c(0,0,0) and the second
> specifies order=c(1,0,0).
> In the first, since there is no auto-regression, all the variance is
> "assigned" to the innovations, hence sigma^2 = 5.233.
> The second case you understand.
> A clue that this was happening is that the first call only returns a
> single coefficient (where is the autoregressive coefficient? - not there
> because you didn't ask for it).
> The second call returns two coefficients, as requested/expected.
>
> HTH,
> Eric
>
>
> On Wed, Nov 14, 2018 at 12:08 PM Ashim Kapoor 
> wrote:
>
>> Dear Eric and William,
>>
>> Why do the 1st and 2nd incantation of arima return sigma^2 as 5.233 vs
>> .?
>> The help for arima says  --->  sigma2: the MLE of the innovations
>> variance.
>> By that account the 1st result is incorrect. I am a little confused.
>>
>> set.seed(123)
>> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=100,sd=1)
>>
>> # Variance of the innovations, e_t = 1
>>
>> # Variance of b = Var(e_t)/(1-Phi^2) = 1 / (1-.81) = 5.263158
>>
>> arima(b)
>>
>> > arima(b)
>>
>> Call:
>> arima(x = b)
>>
>> Coefficients:
>>   intercept
>> -0.0051
>> s.e. 0.0023
>>
>> sigma^2 estimated as 5.233:  log likelihood = -2246450,  aic = 4492903
>> >
>>
>>
>> arima(b,order= c(1,0,0))
>>
>> Call:
>> arima(x = b, order = c(1, 0, 0))
>>
>> Coefficients:
>>  ar1  intercept
>>   0.8994-0.0051
>> s.e.  0.0004 0.0099
>>
>> sigma^2 estimated as 0.:  log likelihood = -1418870,  aic = 2837747
>> >
>>
>> On Tue, Nov 13, 2018 at 11:07 PM William Dunlap 
>> wrote:
>>
>> > Try supplying the order argument to arima.  It looks like the default is
>> > to estimate only the mean.
>> >
>> > > arima(b, order=c(1,0,0))
>> >
>> > Call:
>> > arima(x = b, order = c(1, 0, 0))
>> >
>> > Coefficients:
>> >  ar1  intercept
>> >   0.8871 0.2369
>> > s.e.  0.0145 0.2783
>> >
>> > sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63
>> >
>> >
>> > Bill Dunlap
>> > TIBCO Software
>> > wdunlap tibco.com
>> >
>> > On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor 
>> > wrote:
>> >
>> >> Dear All,
>> >>
>> >> Here is a reprex:
>> >>
>> >> set.seed(123)
>> >> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
>> >> arima(b)
>> >>
>> >> Call:
>> >> arima(x = b)
>> >>
>> >> Coefficients:
>> >>   intercept
>> >>  0.2250
>> >> s.e. 0.0688
>> >>
>> >> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
>> >> >
>> >>
>> >> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
>> >>
>> >> Many thanks,
>> >> Ashim
>> >>
>> >> [[alternative HTML version deleted]]
>> >>
>> >> __
>> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> 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 -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
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] extrat non diagonal

2018-11-14 Thread William Dunlap via R-help
Another way:

> A <- matrix(1:9,3,3,
dimnames=list(Row=paste0("r",1:3),Col=paste0("c",1:3)))
> A
Col
Row  c1 c2 c3
  r1  1  4  7
  r2  2  5  8
  r3  3  6  9
> matrix( A[row(A)!=col(A)], nrow(A)-1, ncol(A), dimnames=list(NULL,
colnames(A)))
 c1 c2 c3
[1,]  2  4  7
[2,]  3  6  8


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Nov 14, 2018 at 2:32 PM, Richard M. Heiberger 
wrote:

> An even better solution because it has fewer steps.
>
> A <- matrix(1:9, 3, 3)
> A
> B <- A[-1, ]
> B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> B
>
> > A <- matrix(1:9, 3, 3)
> > A
>  [,1] [,2] [,3]
> [1,]147
> [2,]258
> [3,]369
> > B <- A[-1, ]
> > B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> > B
>  [,1] [,2] [,3]
> [1,]247
> [2,]368
> >
> On Wed, Nov 14, 2018 at 2:09 PM Richard M. Heiberger 
> wrote:
> >
> > Steve's method is very slick.
> >
> > I think this is a bit easier to understand.
> >
> > A <- matrix(1:9, 3, 3)
> > A
> > B <- matrix(nrow=2, ncol=3)
> > B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)]
> > B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> > B
> >
> > > A <- matrix(1:9, 3, 3)
> > > A
> >  [,1] [,2] [,3]
> > [1,]147
> > [2,]258
> > [3,]369
> > > B <- matrix(nrow=2, ncol=3)
> > > B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)]
> > > B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> > > B
> >  [,1] [,2] [,3]
> > [1,]247
> > [2,]368
> > >
> > On Wed, Nov 14, 2018 at 11:04 AM S Ellison 
> wrote:
> > >
> > > i) Your code creates w2 but references w1 to create aa.
> > >
> > > So you needed
> > > aa <- matrix(rep(c(0.4, 0.1, 0.2), 3), 3,3)
> > > for a working example.
> > >
> > > ii) This
> > > > matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> > > removes any value that is present in the diagonal of aa. Look up
> ?"%in%" to see what that does; it returns TRUE whenever anything in
> as.numeric(aa) matches anything in your diagonal. All the values in aa
> match one of c(0.4, 0.1, 0.2). So since your whole matrix consists of these
> three numbers, you told R to leave out everything in aa and then create a
> 2x3 matrix with the result. Hence the NAs
> > >
> > > iii) If you want to extract odd parts of a matrix explicitly, see ?"["
> and particularly the section on indexing using arrays
> > >
> > > iv) You can use logical indexing. In the special case of the diagonal,
> you can use diag() to create a matrix of logicals, logically negate that
> and apply that to your matrix:
> > > aa[ !diag(rep(TRUE, 3)) ]
> > >
> > > and, in twoi rows:
> > > matrix( aa[ !diag(rep(TRUE, 3)) ], 2,3)
> > >
> > > > for examplei have this matrix
> > > > w2<-c(0.1,0.2,0.4,0.2,0.4,0.1)
> > > > aa<-matrix(w1,nrow=3,ncol=3)
> > > > aa
> > > >  [,1] [,2] [,3]
> > > > [1,]  0.4  0.4  0.4
> > > > [2,]  0.1  0.1  0.1
> > > > [3,]  0.2  0.2  0.2
> > > >
> > > > if i use this code
> > > > matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> > > >
> > > > i will obtaine this matrix[,1] [,2] [,3]
> > > > [1,]   NA   NA   NA
> > > > [2,]   NA   NA   NA
> > > >
> > > > but me i want this matrix[,1] [,2] [,3]
> > > > [1,]  0.1  0.4  0.4
> > > > [2,]  0.2  0.2  0.1
> > > >
> > > > thank you
> > > >
> > > >   [[alternative HTML version deleted]]
> > > >
> > > > __
> > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > > 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.
> > >
> > >
> > > ***
> > > This email and any attachments are confidential. Any use, copying or
> > > disclosure other than by the intended recipient is unauthorised. If
> > > you have received this message in error, please notify the sender
> > > immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com
> > > and delete this message and any copies from your computer and network.
> > > LGC Limited. Registered in England 2991879.
> > > Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > 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 -- To UNSUBSCRIBE and more, see
> 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]]


Re: [R] extrat non diagonal

2018-11-14 Thread Richard M. Heiberger
An even better solution because it has fewer steps.

A <- matrix(1:9, 3, 3)
A
B <- A[-1, ]
B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
B

> A <- matrix(1:9, 3, 3)
> A
 [,1] [,2] [,3]
[1,]147
[2,]258
[3,]369
> B <- A[-1, ]
> B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> B
 [,1] [,2] [,3]
[1,]247
[2,]368
>
On Wed, Nov 14, 2018 at 2:09 PM Richard M. Heiberger  wrote:
>
> Steve's method is very slick.
>
> I think this is a bit easier to understand.
>
> A <- matrix(1:9, 3, 3)
> A
> B <- matrix(nrow=2, ncol=3)
> B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)]
> B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> B
>
> > A <- matrix(1:9, 3, 3)
> > A
>  [,1] [,2] [,3]
> [1,]147
> [2,]258
> [3,]369
> > B <- matrix(nrow=2, ncol=3)
> > B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)]
> > B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> > B
>  [,1] [,2] [,3]
> [1,]247
> [2,]368
> >
> On Wed, Nov 14, 2018 at 11:04 AM S Ellison  wrote:
> >
> > i) Your code creates w2 but references w1 to create aa.
> >
> > So you needed
> > aa <- matrix(rep(c(0.4, 0.1, 0.2), 3), 3,3)
> > for a working example.
> >
> > ii) This
> > > matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> > removes any value that is present in the diagonal of aa. Look up ?"%in%" to 
> > see what that does; it returns TRUE whenever anything in as.numeric(aa) 
> > matches anything in your diagonal. All the values in aa match one of c(0.4, 
> > 0.1, 0.2). So since your whole matrix consists of these three numbers, you 
> > told R to leave out everything in aa and then create a 2x3 matrix with the 
> > result. Hence the NAs
> >
> > iii) If you want to extract odd parts of a matrix explicitly, see ?"[" and 
> > particularly the section on indexing using arrays
> >
> > iv) You can use logical indexing. In the special case of the diagonal, you 
> > can use diag() to create a matrix of logicals, logically negate that and 
> > apply that to your matrix:
> > aa[ !diag(rep(TRUE, 3)) ]
> >
> > and, in twoi rows:
> > matrix( aa[ !diag(rep(TRUE, 3)) ], 2,3)
> >
> > > for examplei have this matrix
> > > w2<-c(0.1,0.2,0.4,0.2,0.4,0.1)
> > > aa<-matrix(w1,nrow=3,ncol=3)
> > > aa
> > >  [,1] [,2] [,3]
> > > [1,]  0.4  0.4  0.4
> > > [2,]  0.1  0.1  0.1
> > > [3,]  0.2  0.2  0.2
> > >
> > > if i use this code
> > > matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> > >
> > > i will obtaine this matrix[,1] [,2] [,3]
> > > [1,]   NA   NA   NA
> > > [2,]   NA   NA   NA
> > >
> > > but me i want this matrix[,1] [,2] [,3]
> > > [1,]  0.1  0.4  0.4
> > > [2,]  0.2  0.2  0.1
> > >
> > > thank you
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > 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.
> >
> >
> > ***
> > This email and any attachments are confidential. Any use, copying or
> > disclosure other than by the intended recipient is unauthorised. If
> > you have received this message in error, please notify the sender
> > immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com
> > and delete this message and any copies from your computer and network.
> > LGC Limited. Registered in England 2991879.
> > Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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 -- To UNSUBSCRIBE and more, see
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] extrat non diagonal

2018-11-14 Thread Richard M. Heiberger
Steve's method is very slick.

I think this is a bit easier to understand.

A <- matrix(1:9, 3, 3)
A
B <- matrix(nrow=2, ncol=3)
B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)]
B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
B

> A <- matrix(1:9, 3, 3)
> A
 [,1] [,2] [,3]
[1,]147
[2,]258
[3,]369
> B <- matrix(nrow=2, ncol=3)
> B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)]
> B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)]
> B
 [,1] [,2] [,3]
[1,]247
[2,]368
>
On Wed, Nov 14, 2018 at 11:04 AM S Ellison  wrote:
>
> i) Your code creates w2 but references w1 to create aa.
>
> So you needed
> aa <- matrix(rep(c(0.4, 0.1, 0.2), 3), 3,3)
> for a working example.
>
> ii) This
> > matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> removes any value that is present in the diagonal of aa. Look up ?"%in%" to 
> see what that does; it returns TRUE whenever anything in as.numeric(aa) 
> matches anything in your diagonal. All the values in aa match one of c(0.4, 
> 0.1, 0.2). So since your whole matrix consists of these three numbers, you 
> told R to leave out everything in aa and then create a 2x3 matrix with the 
> result. Hence the NAs
>
> iii) If you want to extract odd parts of a matrix explicitly, see ?"[" and 
> particularly the section on indexing using arrays
>
> iv) You can use logical indexing. In the special case of the diagonal, you 
> can use diag() to create a matrix of logicals, logically negate that and 
> apply that to your matrix:
> aa[ !diag(rep(TRUE, 3)) ]
>
> and, in twoi rows:
> matrix( aa[ !diag(rep(TRUE, 3)) ], 2,3)
>
> > for examplei have this matrix
> > w2<-c(0.1,0.2,0.4,0.2,0.4,0.1)
> > aa<-matrix(w1,nrow=3,ncol=3)
> > aa
> >  [,1] [,2] [,3]
> > [1,]  0.4  0.4  0.4
> > [2,]  0.1  0.1  0.1
> > [3,]  0.2  0.2  0.2
> >
> > if i use this code
> > matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> >
> > i will obtaine this matrix[,1] [,2] [,3]
> > [1,]   NA   NA   NA
> > [2,]   NA   NA   NA
> >
> > but me i want this matrix[,1] [,2] [,3]
> > [1,]  0.1  0.4  0.4
> > [2,]  0.2  0.2  0.1
> >
> > thank you
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:14}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] ANNOUNCE: ASA Data Challenge Expo, 2019

2018-11-14 Thread Michael Friendly
On behalf of the American Statistical Association sections mentioned 
below,  I am forwarding the information that recently appeared on the 
Statistical Computing Section web  at 
https://community.amstat.org/stat-computing/data-expo/data-expo-2019.

Old-timers will know that the ASA Data Challenge Expo has been important 
in the history of R development, and a number of these have been used as 
examples in a wide range of teaching and R packages.  Encourage your 
colleagues and students to consider this!

-Michael

Three ASA sections (Computing, Government, and Graphics) are proud to 
sponsor the, now annual, Data Challenge Expo 2019 at the JSM 2019 
meetings. The contest is open to anyone who is interested in 
participating, including college students and professionals from the 
private or public sector. This contest challenges participants to 
analyze a government data set using statistical and visualization tools 
and methods. There will be two award categories – Professional (one 
level with a $500 award) and Student (three levels with awards at 
$1,500, $1,000, and $500).

Contestants will present their results in a speed poster session at the 
JSM and must submit their abstracts to the JSM online system. Presenters 
are responsible for their own JSM registration and travel costs, and any 
other costs associated with JSM attendance. Group submissions are 
acceptable. To enter, contestants must do the following by _February 4, 
2019_.

  * Submit abstract for Speed Poster session to the JSM 2019 website
(http://ww2.amstat.org/meetings/jsm/2019/submissions.cfm). Specify
the Government Statistics Section (GSS) as the main sponsor.
Abstract submission starts _December 3, 2018_.
  * Forward the JSM abstract submission email to Wendy Martinez
(martinez.we...@bls.gov ).

The data set for the Data Challenge Expo 2019 will be the New York City 
Housing and Vacancy Survey. Public use data files and documentation are 
available here: https://www.census.gov/programs-surveys/nychvs.html. 
Contestants must use some portion of the New York City Housing and 
Vacancy Survey data, but can also combine other data sources in the 
analysis. If you have any questions on the Data Challenge Expo 2019 
please reach out to Wendy Martinez.

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, ASA Statistical Graphics Section
York University  Voice: 416 736-2100 x66249
4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly
Toronto, ONT  M3J 1P3 CANADA


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] package scorecard

2018-11-14 Thread Javier Marcuzzi
Estimada Dayana Muñoz Gil

Si ni comprendo mal, usted tiene en la base de datos una variable binomial,
digamos que es 0 o 1, ¿que posibilidad hay que en realidad en la base de
datos los registros sean 0, 1 y null? o 0 y 1 en el mismo registro, hay
bases de datos que permiten más de un chequeo y los guardan a todos, otras
solo uno solo con si o no.

Javier Rubén Marcuzzi

El mié., 14 nov. 2018 a las 11:17, Dayana Muñoz ()
escribió:

> Estimadados,
>
> Me encuentro trabajando con variar librerías del paquete scorecard, pero
> al trabajar con mi base de datos, me arroja un problema inusual. Al momento
> de usar el var_filter, donde mi base de datos es de 830.000 registros
> aproximadamente, y tengo 28 variables, entre ellas mi variable binomial
> "Y", me muestra el siguiente error...
>
> > dt_sel = var_filter(data, "Y")
>
> There are 2 variables have too many unique character/factor values, which
> might cause the binning process slow. Please double check the following
> variables:
> RUT, Score
>
> Continue the binning process?
>
> 1: yes
> 2: no
>
> Selection: 1
>
> Variable filtering on 833944 rows and 27 columns in  0: 0:32
> 2 variables are removed
> Warning message:
> In rmcol_datetime_unique1(dt) :
>   There are 1 columns have only one unique values, which are removed from
> input dataset.
>  (ColumnNames: Intercepto_SCORE)
>
>
>
> Si alguien me pudiera ayudar lo agradeceré
>
>
> DAYANA MUÑOZ GIL
> Ingeniero  Estadístico
> Universidad de Valparaíso
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] How to create gridded data

2018-11-14 Thread MacQueen, Don via R-help
Sarah's answer is probably the best approach, but to do it using very basic R 
methods that predate the very good spatial support that R now has, I would 
likely do this:

## Thanks, Jim Lemon, for this step:
df1 <- read.table(text=
"latitude   longitude   Precip
45.5   110.5 3.2
45.5   1115.0
45.5   111.5 1.8
45.5   1122.0
46  110.5 6.1
46  1114.5
46  111.5 7.8
46  1125.5",
header=TRUE)

## first sort
df1 <- df1[order(df1$latitude, df1$longitude) , ]

## convert vector of precipitations to matrix
df2 <- matrix(df1$Precip, nrow=length(unique(df1$latitude)), byrow=TRUE)

## reorder the latitudes (rows)
df2 <- df2[ nrow(df2):1 , ]

## > df2
##  [,1] [,2] [,3] [,4]
## [1,]  6.1  4.5  7.8  5.5
## [2,]  3.2  5.0  1.8  2.0

## From the original question:
## DF2
## 6.1   4.5   7.8   5.5
## 3.2   5.0   1.8   2.0
## ...

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 11/13/18, 8:50 PM, "R-help on behalf of lily li" 
 wrote:

Thanks, Sarah's answer helps the question. Now how to change the gridded
data back to DF1 format? I don't know how to name the format, thanks.

On Tue, Nov 13, 2018 at 10:56 PM David L Carlson  wrote:

> Sarah's answer is probably better depending on what you want to do with
> the resulting data, but here's a way to go from your original DF1 to DF2:
>
> > DF1 <- structure(list(latitude = c(45.5, 45.5, 45.5, 45.5, 46, 46, 46,
> + 46), longitude = c(110.5, 111, 111.5, 112, 110.5, 111, 111.5,
> + 112), Precip = c(3.2, 5, 1.8, 2, 6.1, 4.5, 7.8, 5.5)),
> + class = "data.frame", row.names = c(NA, -8L))
> >
> # Convert to table with xtabs()
> > DF2 <- xtabs(Precip~latitude+longitude, DF1)
> >
>
> # Reverse the order of the latitudes
> > DF2 <- DF2[rev(rownames(DF2)), ]
> > DF2
> longitude
> latitude 110.5 111 111.5 112
> 46 6.1 4.5   7.8 5.5
> 45.5   3.2 5.0   1.8 2.0
>
> # Convert to a data frame
> > DF2 <- as.data.frame.matrix(DF2)
> > DF2
>  110.5 111 111.5 112
> 46 6.1 4.5   7.8 5.5
> 45.5   3.2 5.0   1.8 2.0
>
> 
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77843-4352
>
>
> -Original Message-
> From: R-help  On Behalf Of Sarah Goslee
> Sent: Tuesday, November 13, 2018 8:16 AM
> To: lily li 
> Cc: r-help 
> Subject: Re: [R] How to create gridded data
>
> If you want an actual spatial dataset, the best place to ask is R-sig-geo
>
> R has substantial capabilities for dealing with gridded spatial data,
> including in the sp, raster, and sf packages.
>
> Here's one approach, creating a SpatialGridDataFrame, which can be
> exported in any standard raster format using the rgdal package.
>
> DF2 <- DF1
> coordinates(DF2) <- ~longitude + latitude
> gridded(DF2) <- TRUE
> fullgrid(DF2) <- TRUE
>
> I recommend Roger Bivand's excellent book:
> https://www.springer.com/us/book/9781461476177
>
> and there are abundant web tutorials.
>
> Sarah
> On Tue, Nov 13, 2018 at 2:22 AM lily li  wrote:
> >
> > Hi R users,
> >
> > I have a question about manipulating data. For example, I have DF1 as 
the
> > following, how to transform it to a gridded dataset DF2? In DF2, each
> value
> > Precip is an attribute of the corresponding grid cell. So DF2 is like a
> > spatial surface, and can be imported to ArcGIS. Thanks for your help.
> >
> > DF1
> > latitude   longitude   Precip
> > 45.5   110.5 3.2
> > 45.5   1115.0
> > 45.5   111.5 1.8
> > 45.5   1122.0
> > 46  110.5 6.1
> > 46  1114.5
> > 46  111.5 7.8
> > 46  1125.5
> > ...
> >
> >
> > DF2
> > 6.1   4.5   7.8   5.5
> > 3.2   5.0   1.8   2.0
> > ...
> >
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
  

Re: [R-es] Los puntos no tapen el mapa hecho ggplot

2018-11-14 Thread Manuel Mendoza

Gracias Juan Diego, se trataba exactamente de eso, y claro, funcionó.
Como decía, ese es el código que utilizo para hacer los mapas, pero no  
sé exactamente cómo funciona cada una de sus partes. Yo probé a copiar  
esa misma línea más abajo pero me daba error porque no lo hacía  
correctamente.

Gracias,
Manuel



Quoting Juan Diego Alcaraz-Hernández :


No entieno muy bien lo que preguntas. Además, los datos de Data no están
disponibles por lo que no puedo ver como quedaría el gráfico.
Sin embargo, si lo que quieres es que la linea de los mapas "tape" los
puntos que están cerca de los puntos, debes de copiar el mismo código para
visualizar el mapa debajo de los línea de puntos, de esta manera:

ggplot(legend=FALSE)+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
theme(panel.background=element_blank())+
theme(panel.grid.major = element_blank())+
theme(panel.grid.minor = element_blank())+
theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
theme(axis.ticks = element_blank())+
xlab("") + ylab("")+
geom_point(data=Data,aes(x=lon,y=lat,color= value),size=1.5) +
scale_colour_gradient2(low = "white", mid = "blue",high = "red",
midpoint = 175,guide="colourbar",limits=c(0,350))+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
labs(title =  "Depth of changes"))

Es lo que yo hago, no se si habrá otra manera... :-)

Tambien pudes unir los "theme" con comas y como preferencia personal, yo lo
pondría al final del código...

ggplot(legend=FALSE)+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
  geom_point(data=Data,aes(x=lon,y=lat,color= value),size=1.5) +
  scale_colour_gradient2(low = "white", mid = "blue",high = "red", midpoint
= 175,guide="colourbar",limits=c(0,350))+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
  theme(panel.background=element_blank(),
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  axis.text.x=element_blank(),
  axis.text.y=element_blank(),
  axis.ticks = element_blank())+
xlab("") +
ylab("")+
labs(title =  "Depth of changes"))


El mié., 14 nov. 2018 a las 12:35, Manuel Mendoza ()
escribió:


Buenos días. Hago mis mapas con el código que os copio abajo, pero me
gustaría que me dibujase las líneas del mapa después de poner los
puntos para que se vean. Puedo hacer los puntos más pequeños, pero
entonces quedan separados y yo quiero que rellenen el mapa.
Gracias, como siempre,
Manuel

print(ggplot(legend=FALSE)+geom_path(data=map_data('world'),
aes(x=long, y=lat,group=group))+

theme(panel.background=element_blank())+theme(panel.grid.major =
element_blank())+
   theme(panel.grid.minor =

element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
   theme(axis.ticks = element_blank())+xlab("") + ylab("")+
   geom_point(data=Data,aes(x=lon,y=lat,color=
value),size=1.5) +
   scale_colour_gradient2(low = "white", mid =
"blue",high = "red", midpoint = 175,
   guide="colourbar",limits=c(0,350))+
   labs(title =  "Depth of changes"))

























.

--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es




--
Juan Diego Alcaraz Hernández

http://juandiegoalcaraz.wordpress.com/
Research Group on Ecology of Inland Waters (GRECO)
Research Group on Aquatic Ecology (EcoAqua)
Institute of Aquatic Ecology
University of Girona

·´¯`·.¸¸..><º>.·´¯`·.¸¸.·´¯`·.¸><º>`·.¸¸.·´¯`·.¸
<º><`·.¸¸.·´¯`·.¸.<º><.¸. , . .·´¯`·.. <º><¸.·



--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] extrat non diagonal

2018-11-14 Thread S Ellison
> With your code you just remove diagonal elements from your matrix. 
Worse; it removed _all_ elements from the matrix that match _anything_ in the 
diagonal!
Which, in that example, was everything ...




***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] extrat non diagonal

2018-11-14 Thread S Ellison
i) Your code creates w2 but references w1 to create aa.

So you needed 
aa <- matrix(rep(c(0.4, 0.1, 0.2), 3), 3,3)
for a working example.

ii) This
> matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
removes any value that is present in the diagonal of aa. Look up ?"%in%" to see 
what that does; it returns TRUE whenever anything in as.numeric(aa) matches 
anything in your diagonal. All the values in aa match one of c(0.4, 0.1, 0.2). 
So since your whole matrix consists of these three numbers, you told R to leave 
out everything in aa and then create a 2x3 matrix with the result. Hence the NAs

iii) If you want to extract odd parts of a matrix explicitly, see ?"[" and 
particularly the section on indexing using arrays

iv) You can use logical indexing. In the special case of the diagonal, you can 
use diag() to create a matrix of logicals, logically negate that and apply that 
to your matrix:
aa[ !diag(rep(TRUE, 3)) ]

and, in twoi rows:
matrix( aa[ !diag(rep(TRUE, 3)) ], 2,3)

> for examplei have this matrix
> w2<-c(0.1,0.2,0.4,0.2,0.4,0.1)
> aa<-matrix(w1,nrow=3,ncol=3)
> aa
>  [,1] [,2] [,3]
> [1,]  0.4  0.4  0.4
> [2,]  0.1  0.1  0.1
> [3,]  0.2  0.2  0.2
> 
> if i use this code
> matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
> 
> i will obtaine this matrix[,1] [,2] [,3]
> [1,]   NA   NA   NA
> [2,]   NA   NA   NA
> 
> but me i want this matrix[,1] [,2] [,3]
> [1,]  0.1  0.4  0.4
> [2,]  0.2  0.2  0.1
> 
> thank you
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] extrat non diagonal

2018-11-14 Thread malika yassa via R-help
hello
for examplei have this matrix
w2<-c(0.1,0.2,0.4,0.2,0.4,0.1)aa<-matrix(w1,nrow=3,ncol=3)aa
 [,1] [,2] [,3]
[1,]  0.4  0.4  0.4
[2,]  0.1  0.1  0.1
[3,]  0.2  0.2  0.2

if i use this code 
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)

i will obtaine this matrix[,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]   NA   NA   NA

but me i want this matrix[,1] [,2] [,3]
[1,]  0.1  0.4  0.4
[2,]  0.2  0.2  0.1

thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] lm equivalent of Welch-corrected t-test?

2018-11-14 Thread peter dalgaard



> On 13 Nov 2018, at 16:19 , Paul Johnson  wrote:
> 
> Long ago, when R's t.test had var.equal=TRUE by default, I wrote some
> class notes showing that the result was equivalent to a one predictor
> regression model.  Because t.test does not default to var.equal=TRUE
> these days, I'm curious to know if there is a way to specify weights
> in an lm to obtain the same result as the Welch-adjusted values
> reported by t.test at the current time.  Is there a WLS equivalent
> adjustment with lm?
> 

The short answer is no. The long answer is to look into heteroscedasticity 
adjustments or lmer combined with pbkrtest. 

Well, you can do the weights in lm() and get the right t statistic, but not the 
Satterthwaite oddball-df thing (the sleep data are actually paired, but ignore 
that here)

variances <- tapply(sleep$extra, sleep$group, var)
sleep$wt <- 1/variances[sleep$group]
t.test(extra~group, sleep)
summary(lm(extra~factor(group), weight=wt, sleep))


The pbkrtest approach goes like this:

library(lme4)
library(pbkrtest)
sleep$gdummy <- sleep$group-1 # arrange that this is 1 in the group with larger 
variance
fit1 <-  lmer(extra ~ group + (gdummy+0 | ID), sleep)
fit0 <-  lmer(extra ~ 1 + (gdummy+0 | ID), sleep)
KRmodcomp(fit0, fit1)

(This somewhat abuses the existing sleep$ID -- all you really need is something 
that has a level for each record where gdummy==1)

This ends up with 

 stat ndf ddf F.scaling p.value  
Ftest  3.4626  1. 17.7765 1 0.07939 .

to be compared with the Welch test

t = -1.8608, df = 17.776, p-value = 0.07939


-pd 


> Here's example code to show that lm is same as t.test with var.equal.
> The signs come out differently, but otherwise the effect estimate,
> standard error, t value are same:
> 
> 
> set.seed(234234)
> dat <- data.frame(x = gl(2, 50, labels = c("F", "M")))
> dat$err <- rnorm(100, 0, 1)
> dat$y <- ifelse(dat$x == "F", 40 + dat$err, 44 + dat$err)
> m1 <- lm(y ~ x, dat)
> summary(m1)
> m1.t <- t.test(y ~ x, dat, var.equal = TRUE)
> m1.t
> ## diff matches regression coefficient
> (m1.t.effect <- diff(m1.t$estimate))
> ## standard error matches regression se
> m1.t.stderr <- m1.t.effect/m1.t$statistic
> 
> If you run that, you see lm output:
> 
> Coefficients:
>Estimate Std. Error t value Pr(>|t|)
> (Intercept)  39.9456 0.1180  338.65   <2e-16 ***
> xM3.9080 0.1668   23.43   <2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> Residual standard error: 0.8341 on 98 degrees of freedom
> Multiple R-squared:  0.8485,Adjusted R-squared:  0.8469
> F-statistic: 548.8 on 1 and 98 DF,  p-value: < 2.2e-16
> 
> and t.test:
> 
>> m1.t <- t.test(y ~ x, dat, var.equal = TRUE)
>> m1.t
> 
>Two Sample t-test
> 
> data:  y by x
> t = -23.427, df = 98, p-value < 2.2e-16
> alternative hypothesis: true difference in means is not equal to 0
> 95 percent confidence interval:
> -4.239038 -3.576968
> sample estimates:
> mean in group F mean in group M
>   39.9455843.85358
> 
>> (m1.t.effect <- diff(m1.t$estimate))
> mean in group M
>   3.908003
>> m1.t.effect/m1.t$statistic
> mean in group M
> -0.1668129
> 
> 
> 
> 
> -- 
> Paul E. Johnson   http://pj.freefaculty.org
> Director, Center for Research Methods and Data Analysis http://crmda.ku.edu
> 
> To write to me directly, please address me at pauljohn at ku.edu.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] extrat non diagonal

2018-11-14 Thread PIKAL Petr
Hi

Your mail is mess due to HTML formating. Please use plain taxt mail.
You got an advice, did you try it?

With your code you just remove diagonal elements from your matrix. If this is 
not your intention, you should specify more clearly what do you want to achieve 
as the result.

Cheers
Petr
> -Original Message-
> From: R-help  On Behalf Of malika yassa via R-
> help
> Sent: Wednesday, November 14, 2018 1:09 PM
> To: R-help Mailing List 
> Subject: [R] extrat non diagonal
>
> helloi didn't obtaine the matrix after extrat non diagonalmy programx<-
> rnorm(6,0,1)
>
> aa<-matrix(x,nrow=6,ncol=6)
> matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)
>
> nrow=5ncol=6thank you
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] extrat non diagonal

2018-11-14 Thread malika yassa via R-help
helloi didn't obtaine the matrix after extrat non diagonalmy 
programx<-rnorm(6,0,1)

aa<-matrix(x,nrow=6,ncol=6)
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)

nrow=5ncol=6thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Help with Centroids

2018-11-14 Thread Robert David Burbidge via R-help
# construct the dataframe
`TK-QUADRANT` <- c(9161,9162,9163,9164,10152,10154,10161,10163)
LAT <- 
c(55.07496,55.07496,55.02495,55.02496,54.97496,54.92495,54.97496,54.92496)
LON <- 
c(8.37477,8.458109,8.37477,8.45811,8.291435,8.291437,8.374774,8.374774)
df <- data.frame(`TK-QUADRANT`=`TK-QUADRANT`,LAT=LAT,LON=LON)

# group the data and calculate means by group
df$group <- floor(df$TK.QUADRANT/10)*10
out <- aggregate(df[c('LAT','LON')],by=list(df$group),mean)
print(out)

# see also:
# 
https://livefreeordichotomize.com/2018/06/27/bringing-the-family-together-finding-the-center-of-geographic-points-in-r/

Rgds,
Robert
On 14/11/2018 11:13, sasa kosanic wrote:
>  Dear Robert,
> Thank  you for your very much for your reply. Please see attached pdf  
> fille.
> I hope now it is more clear what I am trying to do:
> calculate new latitude and  longitude  of the centroids from the 
> existing cells...
> as you can see from the attached pdf.  from Lat/ Long of 
> 9161,9162,9163,9164 I need to calculate a single Lat/Long that could 
> be fore example called 9160
> and then from lat/ long of 10152 and 10154 a  new single lat/long 
> called 10150 .
> But guess I would need some kind of loop as this is just an example 
> table  and the the whole table is covering whole Germany.
> Please let me know if it is still not clear what I am trying to do here.
>
> Best wishes,
> Sasha
>
> On Wed, 14 Nov 2018 at 07:58, Robert David Burbidge 
>  > wrote:
>
> Hi Sasha,
>
> Your attached table did not come through, please see the posting
> guidelines:
> "No binary attachments except for PS, PDF, and some image and archive
> formats (others are automatically stripped off because they can
> contain
> malicious software). Files in other formats and larger ones should
> rather be put on the web and have only their URLs posted. This way a
> reader has the option to download them or not."
> https://www.r-project.org/posting-guide.html
>
> It is not clear what you are trying to do. As a first step it
> looks like
> you want something like:
>  
> lat <- c(9161,9162,9163,9164,10152,10154)
> floor(lat/10)*10
> 
>
> Please provide further details on what you are trying to do.
>
> Rgds,
>
> Robert
>
>
> On 13/11/2018 09:51, sasa kosanic wrote:
> > Dear All, I am pretty new to R and would appreciate a help how to
> > calculate centroids from the latitude and longitude of existing
> cells
> > (e.g. to get centroid for a new cell I would need to combine
> latitude
> > and 9161,9162,9163,9164 to 9160 or 10152, 10154 to 10150 etc.)
> Please
> > see attached table. Thank you very much! Best, Sasha
>
>
>
> -- 
>
> Dr Sasha Kosanic
> Ecology Lab (Biology Department)
> Room M644
> University of Konstanz
> Universitätsstraße 10
> D-78464 Konstanz
> Phone: +49 7531 883321 & +49 (0)175 9172503
>
> http://cms.uni-konstanz.de/vkleunen/
> https://tinyurl.com/y8u5wyoj
> https://tinyurl.com/cgec6tu
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] extrat non diagonal value

2018-11-14 Thread Michael Dewey
When that arrived it was a complete mess since you posted in HTML which 
scrambles your code and you sent code which had syntax errors. Please 
try again by posting in plain text and cut and paste your code. It would 
also help if you stated exactly what you expected your output to consist of.


Michael

On 14/11/2018 11:19, malika yassa via R-help wrote:

helloplease i have this matrixx<-rnorm(6,0,1)

aa<-matrix(x,nrow=6,ncol=6)

i have to extrat non diagonal value, i use this code
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)

but i didn't get the resultthank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] Los puntos no tapen el mapa hecho ggplot

2018-11-14 Thread Juan Diego Alcaraz-Hernández
No entieno muy bien lo que preguntas. Además, los datos de Data no están
disponibles por lo que no puedo ver como quedaría el gráfico.
Sin embargo, si lo que quieres es que la linea de los mapas "tape" los
puntos que están cerca de los puntos, debes de copiar el mismo código para
visualizar el mapa debajo de los línea de puntos, de esta manera:

ggplot(legend=FALSE)+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
theme(panel.background=element_blank())+
theme(panel.grid.major = element_blank())+
theme(panel.grid.minor = element_blank())+
theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
theme(axis.ticks = element_blank())+
xlab("") + ylab("")+
geom_point(data=Data,aes(x=lon,y=lat,color= value),size=1.5) +
scale_colour_gradient2(low = "white", mid = "blue",high = "red",
midpoint = 175,guide="colourbar",limits=c(0,350))+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
labs(title =  "Depth of changes"))

Es lo que yo hago, no se si habrá otra manera... :-)

Tambien pudes unir los "theme" con comas y como preferencia personal, yo lo
pondría al final del código...

ggplot(legend=FALSE)+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
  geom_point(data=Data,aes(x=lon,y=lat,color= value),size=1.5) +
  scale_colour_gradient2(low = "white", mid = "blue",high = "red", midpoint
= 175,guide="colourbar",limits=c(0,350))+
  geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
  theme(panel.background=element_blank(),
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  axis.text.x=element_blank(),
  axis.text.y=element_blank(),
  axis.ticks = element_blank())+
xlab("") +
ylab("")+
labs(title =  "Depth of changes"))


El mié., 14 nov. 2018 a las 12:35, Manuel Mendoza ()
escribió:

> Buenos días. Hago mis mapas con el código que os copio abajo, pero me
> gustaría que me dibujase las líneas del mapa después de poner los
> puntos para que se vean. Puedo hacer los puntos más pequeños, pero
> entonces quedan separados y yo quiero que rellenen el mapa.
> Gracias, como siempre,
> Manuel
>
> print(ggplot(legend=FALSE)+geom_path(data=map_data('world'),
> aes(x=long, y=lat,group=group))+
>
> theme(panel.background=element_blank())+theme(panel.grid.major =
> element_blank())+
>theme(panel.grid.minor =
>
> element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
>theme(axis.ticks = element_blank())+xlab("") + ylab("")+
>geom_point(data=Data,aes(x=lon,y=lat,color=
> value),size=1.5) +
>scale_colour_gradient2(low = "white", mid =
> "blue",high = "red", midpoint = 175,
>guide="colourbar",limits=c(0,350))+
>labs(title =  "Depth of changes"))
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> .
>
> --
> Dr Manuel Mendoza
> Department of Biogeography and Global Change
> National Museum of Natural History (MNCN)
> Spanish Scientific Council (CSIC)
> C/ Serrano 115bis, 28006 MADRID
> Spain
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Juan Diego Alcaraz Hernández

http://juandiegoalcaraz.wordpress.com/
Research Group on Ecology of Inland Waters (GRECO)
Research Group on Aquatic Ecology (EcoAqua)
Institute of Aquatic Ecology
University of Girona

·´¯`·.¸¸..><º>.·´¯`·.¸¸.·´¯`·.¸><º>`·.¸¸.·´¯`·.¸
<º><`·.¸¸.·´¯`·.¸.<º><.¸. , . .·´¯`·.. <º><¸.·

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] extrat non diagonal value

2018-11-14 Thread PIKAL Petr
Hi.

You did not specify what do you want to do with the result.

functions

upper.tri, lower.tri and diag can manipulate parts of matrices.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of malika yassa via R-
> help
> Sent: Wednesday, November 14, 2018 12:20 PM
> To: R-help Mailing List 
> Subject: [R] extrat non diagonal value
>
> helloplease i have this matrixx<-rnorm(6,0,1)
>
> aa<-matrix(x,nrow=6,ncol=6)
>
> i have to extrat non diagonal value, i use this code
> matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)
>
> but i didn't get the resultthank you
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] Los puntos no tapen el mapa hecho ggplot

2018-11-14 Thread Manuel Mendoza
Buenos días. Hago mis mapas con el código que os copio abajo, pero me  
gustaría que me dibujase las líneas del mapa después de poner los  
puntos para que se vean. Puedo hacer los puntos más pequeños, pero  
entonces quedan separados y yo quiero que rellenen el mapa.

Gracias, como siempre,
Manuel

print(ggplot(legend=FALSE)+geom_path(data=map_data('world'),  
aes(x=long, y=lat,group=group))+
   
theme(panel.background=element_blank())+theme(panel.grid.major =  
element_blank())+
  theme(panel.grid.minor =  
element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+

  theme(axis.ticks = element_blank())+xlab("") + ylab("")+
  geom_point(data=Data,aes(x=lon,y=lat,color=  
value),size=1.5) +
  scale_colour_gradient2(low = "white", mid =  
"blue",high = "red", midpoint = 175,

  guide="colourbar",limits=c(0,350))+
  labs(title =  "Depth of changes"))

























.

--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R] extrat non diagonal value

2018-11-14 Thread malika yassa via R-help
helloplease i have this matrixx<-rnorm(6,0,1)

aa<-matrix(x,nrow=6,ncol=6)

i have to extrat non diagonal value, i use this code
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],5,6)

but i didn't get the resultthank you 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Output of arima

2018-11-14 Thread Eric Berger
Hi Ashim,
Per the help page for arima(), it fits an ARIMA model to the specified time
series - but the caller has to specify the order - i.e. (p,d,q) - of the
model.
The default order is (0,0,0) (per the help page). Hence your two calls are
different. The first call is equivalent to order=c(0,0,0) and the second
specifies order=c(1,0,0).
In the first, since there is no auto-regression, all the variance is
"assigned" to the innovations, hence sigma^2 = 5.233.
The second case you understand.
A clue that this was happening is that the first call only returns a single
coefficient (where is the autoregressive coefficient? - not there because
you didn't ask for it).
The second call returns two coefficients, as requested/expected.

HTH,
Eric


On Wed, Nov 14, 2018 at 12:08 PM Ashim Kapoor  wrote:

> Dear Eric and William,
>
> Why do the 1st and 2nd incantation of arima return sigma^2 as 5.233 vs
> .?
> The help for arima says  --->  sigma2: the MLE of the innovations variance.
> By that account the 1st result is incorrect. I am a little confused.
>
> set.seed(123)
> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=100,sd=1)
>
> # Variance of the innovations, e_t = 1
>
> # Variance of b = Var(e_t)/(1-Phi^2) = 1 / (1-.81) = 5.263158
>
> arima(b)
>
> > arima(b)
>
> Call:
> arima(x = b)
>
> Coefficients:
>   intercept
> -0.0051
> s.e. 0.0023
>
> sigma^2 estimated as 5.233:  log likelihood = -2246450,  aic = 4492903
> >
>
>
> arima(b,order= c(1,0,0))
>
> Call:
> arima(x = b, order = c(1, 0, 0))
>
> Coefficients:
>  ar1  intercept
>   0.8994-0.0051
> s.e.  0.0004 0.0099
>
> sigma^2 estimated as 0.:  log likelihood = -1418870,  aic = 2837747
> >
>
> On Tue, Nov 13, 2018 at 11:07 PM William Dunlap  wrote:
>
> > Try supplying the order argument to arima.  It looks like the default is
> > to estimate only the mean.
> >
> > > arima(b, order=c(1,0,0))
> >
> > Call:
> > arima(x = b, order = c(1, 0, 0))
> >
> > Coefficients:
> >  ar1  intercept
> >   0.8871 0.2369
> > s.e.  0.0145 0.2783
> >
> > sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63
> >
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> > On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor 
> > wrote:
> >
> >> Dear All,
> >>
> >> Here is a reprex:
> >>
> >> set.seed(123)
> >> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
> >> arima(b)
> >>
> >> Call:
> >> arima(x = b)
> >>
> >> Coefficients:
> >>   intercept
> >>  0.2250
> >> s.e. 0.0688
> >>
> >> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
> >> >
> >>
> >> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
> >>
> >> Many thanks,
> >> Ashim
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> 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 -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Output of arima

2018-11-14 Thread Ashim Kapoor
Dear Eric and William,

Why do the 1st and 2nd incantation of arima return sigma^2 as 5.233 vs
.?
The help for arima says  --->  sigma2: the MLE of the innovations variance.
By that account the 1st result is incorrect. I am a little confused.

set.seed(123)
b <- arima.sim(list(order = c(1,0,0),ar= .9),n=100,sd=1)

# Variance of the innovations, e_t = 1

# Variance of b = Var(e_t)/(1-Phi^2) = 1 / (1-.81) = 5.263158

arima(b)

> arima(b)

Call:
arima(x = b)

Coefficients:
  intercept
-0.0051
s.e. 0.0023

sigma^2 estimated as 5.233:  log likelihood = -2246450,  aic = 4492903
>


arima(b,order= c(1,0,0))

Call:
arima(x = b, order = c(1, 0, 0))

Coefficients:
 ar1  intercept
  0.8994-0.0051
s.e.  0.0004 0.0099

sigma^2 estimated as 0.:  log likelihood = -1418870,  aic = 2837747
>

On Tue, Nov 13, 2018 at 11:07 PM William Dunlap  wrote:

> Try supplying the order argument to arima.  It looks like the default is
> to estimate only the mean.
>
> > arima(b, order=c(1,0,0))
>
> Call:
> arima(x = b, order = c(1, 0, 0))
>
> Coefficients:
>  ar1  intercept
>   0.8871 0.2369
> s.e.  0.0145 0.2783
>
> sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor 
> wrote:
>
>> Dear All,
>>
>> Here is a reprex:
>>
>> set.seed(123)
>> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
>> arima(b)
>>
>> Call:
>> arima(x = b)
>>
>> Coefficients:
>>   intercept
>>  0.2250
>> s.e. 0.0688
>>
>> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
>> >
>>
>> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
>>
>> Many thanks,
>> Ashim
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
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.