[R] How to solve this?

2021-08-30 Thread SITI AISYAH ZAKARIA
Dear all,

Can anyone help me? I'm using this coding to get the spatial gev model and
plotting the quantile plot to justify the model is fit but the plot look
like not fit.. How can I solve this? It is I need to change in the any
value at the coding.For example I want to change form.shape <-shape ~1 to
form.shape <- shape ~average shape but is not available for average coding.

below is my coding

#--
# fitspatgev
#--
# response surface model
Ozone<-data.matrix(Ozone_S)
Ozone
LotLatAlt<-data.matrix(OzoneLotLatAlt_S)
LotLatAlt
form.loc <- loc ~ Lon + Lat + Alt
form.scale <- scale ~ 1
form.shape <- shape ~ 1
dim(Ozone_S)
dim(OzoneLotLatAlt_S)
fit1 <- fitspatgev(Ozone, scale(LotLatAlt,scale=FALSE), form.loc,
form.scale, form.shape);fit1
TIC(fit1)
fit1$param
#data(rain
#symbolplot(rain, coord, plot.border = swiss)
#check the fit of the model: compute QQplots for each station
par(mfrow=c(1,3))
par(mar=c(3,2.5,1.5,0.5),mgp=c(1.5,0.5,0),font.main=1,cex=0.66,cex.main=1)
#calculation of confidance intervals
nc <- 1
M1 <- matrix(rfrechet(nc*nobs),nrow=nobs,ncol=nc)
M <- t(apply(M1,2,sort))
E <- boot::envelope(mat=M) #compute 95% confidance bands
for (k in c(1:3,4,5,6)){ #choose some stations
  park <- predict(fit1)[k,]
  fk <- gev2frech(Ozone[,k],loc=park[4],scale=park[5],shape=park[6])
  qqplot(y=fk,x=qfrechet((1:nobs)/(nobs+1)),log='xy',main=k,ylab='Sample
Quantiles',xlab='Theoretical Quantiles',cex=0.7);
  abline(0,1)
  lines(y=E$overall[1,],x=qfrechet((1:nobs)/(nobs +1)),lty='dotted')
  lines(y=E$overall[2,],x=qfrechet((1:nobs)/(nobs +1)),lty='dotted')
}

the quantile plot is in attachment file.
please, can anyone help me?

thank you

-- 





"..Millions of trees are used to make papers, only to be thrown away 
after a couple of minutes reading from them. Our planet is at stake. Please 
be considerate. THINK TWICE BEFORE PRINTING THIS.."

DISCLAIMER: This email 
and any files transmitted with it are confidential and intended solely for 
the use of the individual orentity to whom they are addressed. If you have 
received this email in error please notify the UniMAP's Email 
Administrator. Please note that any views or opinions presented in this 
email are solely those of the author and do not necessarily represent those 
of the university. Finally, the recipient should check this email and any 
attachments for the presence of viruses.The university accepts no liability 
for any damage caused by any virus transmitted by this email.

Universiti 
Malaysia Perlis (UniMAP) | Digital Management & Development Centre (DMDC), 
Universiti Malaysia Perlis (UniMAP), Pauh Putra Campus, 02600 Arau, Perlis, 
MALAYSIA | www.unimap.edu.my 
__
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] HOW TO SOLVE THIS PROBLEM (RVALS)

2021-08-08 Thread SITI AISYAH ZAKARIA
Hi,

Can anyone help me how to solve this problem?

 #calculation of confidence intervals
1. > nc <- 1
2. > M1 <- matrix(rfrechet(nc*nobs),nrow=nobs,ncol=nc)
3. > M <- t(apply(M1,2,sort))
4. > E <- envelope(mat=M) #compute 95% confidance bands
*Error in envelope.matrix(mat = M) : rvals must be supplied*

My problem is after I run my coding in line 4 the error is highlighted red
is come out. I don't know how to solve it. Please help me.

Thank you

-- 





"..Millions of trees are used to make papers, only to be thrown away 
after a couple of minutes reading from them. Our planet is at stake. Please 
be considerate. THINK TWICE BEFORE PRINTING THIS.."

DISCLAIMER: This email \ and any files transmitte...{{dropped:24}}

__
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] How to estimate the parameter for many variable?

2021-07-10 Thread SITI AISYAH ZAKARIA
Dear Rui and Jim,

Thank you very much for your feedback.

Yes, now I get the output. And after this I will use this output as the
marginal distribution to continue the analysis on spatial extremes.


Thanks again. See you later.

On Fri, 9 Jul 2021 at 17:18, Rui Barradas  wrote:

> Hello,
>
> With the condition for the location it can be estimated like the following.
>
>
> fit_list2 <- gev_fit_list <- lapply(Ozone_weekly2, gev.fit, ydat = ti,
> mul = c(2, 3), show = FALSE)
> mle_params2 <- t(sapply(fit_list2, '[[', 'mle'))
> # assign column names
> colnames(mle_params2) <- c("location", "scale", "shape", "mul2", "mul3")
> head(mle_params2)
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 09:53 de 09/07/21, SITI AISYAH ZAKARIA escreveu:
> > Dear Rui ang Jim,
> >
> > Thank you very much.
> >
> > Thank you Rui Barradas, I already tried using your coding and I'm
> > grateful I got the answer.
> >
> > ok now, I have some condition on the location parameter which is cyclic
> > condition.
> >
> > So, I will add another 2 variables for the column.
> >
> > and the condition for location is this one.
> >
> >   ti[,1] = seq(1, 888, 1)
> >ti[,2]=sin(2*pi*(ti[,1])/52)
> >ti[,3]=cos(2*pi*(ti[,1])/52)
> >fit0<-gev.fit(x[,i], ydat = ti, mul=c(2, 3))
> >
> > Thank you again.
> >
> > On Fri, 9 Jul 2021 at 14:38, Rui Barradas  > <mailto:ruipbarra...@sapo.pt>> wrote:
> >
> > Hello,
> >
> > The following lapply one-liner fits a GEV to each column vector,
> there
> > is no need for the double for loop. There's also no need to create a
> > data set x.
> >
> >
> > library(ismev)
> > library(mgcv)
> > library(EnvStats)
> >
> > Ozone_weekly2 <- read.table("~/tmp/Ozone_weekly2.txt", header = TRUE)
> >
> > # fit a GEV to each column
> > gev_fit_list <- lapply(Ozone_weekly2, gev.fit, show = FALSE)
> >
> > # extract the parameters MLE estimates
> > mle_params <- t(sapply(gev_fit_list, '[[', 'mle'))
> >
> > # assign column names
> > colnames(mle_params) <- c("location", "scale", "shape")
> >
> > # see first few rows
> > head(mle_params)
> >
> >
> >
> > The OP doesn't ask for plots but, here they go.
> >
> >
> > y_vals <- function(x, params){
> > loc <- params[1]
> > scale <- params[2]
> > shape <- params[3]
> > EnvStats::dgevd(x, loc, scale, shape)
> > }
> > plot_fit <- function(data, vec, verbose = FALSE){
> > fit <- gev.fit(data[[vec]], show = verbose)
> > x <- sort(data[[vec]])
> > hist(x, freq = FALSE)
> > lines(x, y_vals(x, params = fit$mle))
> > }
> >
> > # seems a good fit
> > plot_fit(Ozone_weekly2, 1)   # column number
> > plot_fit(Ozone_weekly2, "CA01")  # col name, equivalent
> >
> > # the data seems gaussian, not a good fit
> > plot_fit(Ozone_weekly2, 4)   # column number
> > plot_fit(Ozone_weekly2, "CA08")  # col name, equivalent
> >
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> >
> > Às 00:59 de 09/07/21, SITI AISYAH ZAKARIA escreveu:
> >  > Dear all,
> >  >
> >  > Thank you very much for the feedback.
> >  >
> >  > Sorry for the lack of information about this problem.
> >  >
> >  > Here, I explain again.
> >  >
> >  > I use this package to run my coding.
> >  >
> >  > library(ismev)
> >  > library(mgcv)
> >  > library(nlme)
> >  >
> >  > The purpose of this is I want to get the value of parameter
> > estimation
> >  > using MLE by applying the GEV distribution.
> >  >
> >  > x <- data.matrix(Ozone_weekly2)  x refers to
> > my data
> >  > that consists of 19 variables. I will attach the data together.
> >  > x
> >  > head(gev.fit)[1:4]
> >  > ti = matrix(ncol = 3, nrow = 888)
> >  > ti[,1] = seq(1, 888, 1)
> >  > ti[,2]=sin(2*pi*(ti[,1])/52)
> >  > ti[,3]=cos(2*pi*(ti[,1])/52)
> >  >
> >  > /for(i in 1:nrow(x))
> > 

Re: [R] How to estimate the parameter for many variable?

2021-07-09 Thread SITI AISYAH ZAKARIA
Dear Rui ang Jim,

Thank you very much.

Thank you Rui Barradas, I already tried using your coding and I'm grateful
I got the answer.

ok now, I have some condition on the location parameter which is cyclic
condition.

So, I will add another 2 variables for the column.

and the condition for location is this one.

 ti[,1] = seq(1, 888, 1)
  ti[,2]=sin(2*pi*(ti[,1])/52)
  ti[,3]=cos(2*pi*(ti[,1])/52)
  fit0<-gev.fit(x[,i], ydat = ti, mul=c(2, 3))

Thank you again.

On Fri, 9 Jul 2021 at 14:38, Rui Barradas  wrote:

> Hello,
>
> The following lapply one-liner fits a GEV to each column vector, there
> is no need for the double for loop. There's also no need to create a
> data set x.
>
>
> library(ismev)
> library(mgcv)
> library(EnvStats)
>
> Ozone_weekly2 <- read.table("~/tmp/Ozone_weekly2.txt", header = TRUE)
>
> # fit a GEV to each column
> gev_fit_list <- lapply(Ozone_weekly2, gev.fit, show = FALSE)
>
> # extract the parameters MLE estimates
> mle_params <- t(sapply(gev_fit_list, '[[', 'mle'))
>
> # assign column names
> colnames(mle_params) <- c("location", "scale", "shape")
>
> # see first few rows
> head(mle_params)
>
>
>
> The OP doesn't ask for plots but, here they go.
>
>
> y_vals <- function(x, params){
>loc <- params[1]
>scale <- params[2]
>shape <- params[3]
>EnvStats::dgevd(x, loc, scale, shape)
> }
> plot_fit <- function(data, vec, verbose = FALSE){
>fit <- gev.fit(data[[vec]], show = verbose)
>x <- sort(data[[vec]])
>hist(x, freq = FALSE)
>lines(x, y_vals(x, params = fit$mle))
> }
>
> # seems a good fit
> plot_fit(Ozone_weekly2, 1)   # column number
> plot_fit(Ozone_weekly2, "CA01")  # col name, equivalent
>
> # the data seems gaussian, not a good fit
> plot_fit(Ozone_weekly2, 4)   # column number
> plot_fit(Ozone_weekly2, "CA08")  # col name, equivalent
>
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 00:59 de 09/07/21, SITI AISYAH ZAKARIA escreveu:
> > Dear all,
> >
> > Thank you very much for the feedback.
> >
> > Sorry for the lack of information about this problem.
> >
> > Here, I explain again.
> >
> > I use this package to run my coding.
> >
> > library(ismev)
> > library(mgcv)
> > library(nlme)
> >
> > The purpose of this is I want to get the value of parameter estimation
> > using MLE by applying the GEV distribution.
> >
> > x <- data.matrix(Ozone_weekly2)  x refers to my data
> > that consists of 19 variables. I will attach the data together.
> > x
> > head(gev.fit)[1:4]
> > ti = matrix(ncol = 3, nrow = 888)
> > ti[,1] = seq(1, 888, 1)
> > ti[,2]=sin(2*pi*(ti[,1])/52)
> > ti[,3]=cos(2*pi*(ti[,1])/52)
> >
> > /for(i in 1:nrow(x))
> >+ { for(j in 1:ncol(x))the problem in
> > here, i don't no to create the coding. i target my output will come out
> > in matrix that
> >  + {x[i,j] = 1}}   show the
> > parameter estimation for 19 variable which have 19 row and 3 column/
> > /  row --
> > refer to variable (station)  ; column -- refer to parameter estimation
> > for GEV distribution
> >
> > /thank you.
> >
> > On Thu, 8 Jul 2021 at 18:40, Rui Barradas  > <mailto:ruipbarra...@sapo.pt>> wrote:
> >
> > Hello,
> >
> > Also, in the code
> >
> > x <- data.matrix(Ozone_weekly)
> >
> > [...omited...]
> >
> > for(i in 1:nrow(x))
> > + { for(j in 1:ncol(x))
> >   + {x[i,j] = 1}}
> >
> > not only you rewrite x but the double for loop is equivalent to
> >
> >
> > x[] <- 1
> >
> >
> > courtesy R's vectorised behavior. (The square parenthesis are needed
> to
> > keep the dimensions, the matrix form.)
> > And, I'm not sure but isn't
> >
> > head(gev.fit)[1:4]
> >
> > equivalent to
> >
> > head(gev.fit, n = 4)
> >
> > ?
> >
> > Like Jim says, we need more information, can you post Ozone_weekly2
> and
> > the code that produced gev.fit? But in the mean time you can revise
> > your
> > code.
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> >
> > Às 11:08 de 08/07/21, Jim Lemon escreveu:
> >      > Hi Siti,
> >  > I think 

Re: [R] How to estimate the parameter for many variable?

2021-07-09 Thread SITI AISYAH ZAKARIA
Dear all,

Thank you very much for the feedback.

Sorry for the lack of information about this problem.

Here, I explain again.

I use this package to run my coding.

library(ismev)
library(mgcv)
library(nlme)

The purpose of this is I want to get the value of parameter estimation
using MLE by applying the GEV distribution.

x <- data.matrix(Ozone_weekly2)  x refers to my data
that consists of 19 variables. I will attach the data together.
x
head(gev.fit)[1:4]
ti = matrix(ncol = 3, nrow = 888)
ti[,1] = seq(1, 888, 1)
ti[,2]=sin(2*pi*(ti[,1])/52)
ti[,3]=cos(2*pi*(ti[,1])/52)



*for(i in 1:nrow(x))  + { for(j in 1:ncol(x))
the problem in here, i don't no to create the coding. i target my
output will come out in matrix that + {x[i,j] = 1}}
   show the parameter estimation for 19 variable which have
19 row and 3 column*


*  row -- refer
to variable (station)  ; column -- refer to parameter estimation for GEV
distribution*thank you.

On Thu, 8 Jul 2021 at 18:40, Rui Barradas  wrote:

> Hello,
>
> Also, in the code
>
> x <- data.matrix(Ozone_weekly)
>
> [...omited...]
>
> for(i in 1:nrow(x))
>+ { for(j in 1:ncol(x))
>  + {x[i,j] = 1}}
>
> not only you rewrite x but the double for loop is equivalent to
>
>
> x[] <- 1
>
>
> courtesy R's vectorised behavior. (The square parenthesis are needed to
> keep the dimensions, the matrix form.)
> And, I'm not sure but isn't
>
> head(gev.fit)[1:4]
>
> equivalent to
>
> head(gev.fit, n = 4)
>
> ?
>
> Like Jim says, we need more information, can you post Ozone_weekly2 and
> the code that produced gev.fit? But in the mean time you can revise your
> code.
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 11:08 de 08/07/21, Jim Lemon escreveu:
> > Hi Siti,
> > I think we need a bit more information to respond helpfully. I have no
> > idea what "Ozone_weekly2" is and Google is also ignorant. "gev.fit" is
> > also unknown. The name suggests that it is the output of some
> > regression or similar. What function produced it, and from what
> > library? "ti" is known as you have defined it. However, I don't know
> > what you want to do with it. Finally, as this is a text mailing list,
> > we don't get any highlighting, so the text to which you refer cannot
> > be identified. I can see you have a problem, but cannot offer any help
> > right now.
> >
> > Jim
> >
> > On Thu, Jul 8, 2021 at 12:06 AM SITI AISYAH ZAKARIA
> >  wrote:
> >>
> >> Dear all,
> >>
> >> Can I ask something about programming in marginal distribution for
> spatial
> >> extreme?
> >> I really stuck on my coding to obtain the parameter estimation for
> >> univariate or marginal distribution for new model in spatial extreme.
> >>
> >> I want to run my data in order to get the parameter estimation value
> for 25
> >> stations in one table. But I really didn't get the idea of the correct
> >> coding. Here I attached my coding
> >>
> >> x <- data.matrix(Ozone_weekly2)
> >> x
> >> head(gev.fit)[1:4]
> >> ti = matrix(ncol = 3, nrow = 888)
> >> ti[,1] = seq(1, 888, 1)
> >> ti[,2]=sin(2*pi*(ti[,1])/52)
> >> ti[,3]=cos(2*pi*(ti[,1])/52)
> >> for(i in 1:nrow(x))
> >>+ { for(j in 1:ncol(x))
> >>  + {x[i,j] = 1}}
> >>
> >> My problem is highlighted in red color.
> >> And if are not hesitate to all. Can someone share with me the procedure,
> >> how can I map my data using spatial extreme.
> >> For example:
> >> After I finish my marginal distribution, what the next procedure. It is
> I
> >> need to get the spatial independent value.
> >>
> >> That's all
> >> Thank you.
> >>
> >> --
> >>
> >>
> >>
> >>
> >>
> >> "..Millions of trees are used to make papers, only to be thrown away
> >> after a couple of minutes reading from them. Our planet is at stake.
> Please
> >> be considerate. THINK TWICE BEFORE PRINTING THIS.."
> >>
> >> DISCLAIMER: This email \ and any files transmitte...{{dropped:24}}
> >>
> >> __
> >> 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, repro

[R] How to estimate the parameter for many variable?

2021-07-07 Thread SITI AISYAH ZAKARIA
Dear all,

Can I ask something about programming in marginal distribution for spatial
extreme?
I really stuck on my coding to obtain the parameter estimation for
univariate or marginal distribution for new model in spatial extreme.

I want to run my data in order to get the parameter estimation value for 25
stations in one table. But I really didn't get the idea of the correct
coding. Here I attached my coding

x <- data.matrix(Ozone_weekly2)
x
head(gev.fit)[1:4]
ti = matrix(ncol = 3, nrow = 888)
ti[,1] = seq(1, 888, 1)
ti[,2]=sin(2*pi*(ti[,1])/52)
ti[,3]=cos(2*pi*(ti[,1])/52)
for(i in 1:nrow(x))
  + { for(j in 1:ncol(x))
+ {x[i,j] = 1}}

My problem is highlighted in red color.
And if are not hesitate to all. Can someone share with me the procedure,
how can I map my data using spatial extreme.
For example:
After I finish my marginal distribution, what the next procedure. It is I
need to get the spatial independent value.

That's all
Thank you.

-- 





"..Millions of trees are used to make papers, only to be thrown away 
after a couple of minutes reading from them. Our planet is at stake. Please 
be considerate. THINK TWICE BEFORE PRINTING THIS.."

DISCLAIMER: This email \ and any files transmitte...{{dropped:24}}

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