[R] Determination of variables for optimizing one response using the desirability function

2018-12-25 Thread Thanh Tran
Dear all,



I'm trying to use response surface methodology (rsm package) to . In my
data, the response is KIC, and 4 factors are AC, AV, T, and Temp. A typical
second-degree response modeling is as follows:



> data<-read.csv("2.csv", header =T)

> library(rsm)

> f.quad <- rsm(KIC~SO(AC, AV, T, Temp), data = data)

> summary(f.quad)



I summary the results as follows:



KIC = 4.85 – 2.9AC +0.151 AV + 0.1094T

  + 0.0091Temp + 0.324 AC^2-0.0156AV^2

  - 10.00106T^2 - 0.0009Temp^2 + 0.0071AC´AV

  - 0.00087AC´T -0.00083AC´Temp – 0.0018AV´T

 +0.0015AV´Temp – 0.000374 AV ´ T



Stationary point of response surface:

   ACAV  TTemp

 4.502353|  2.753002 | 48.278146 | -4.246307



Eigenanalysis:

eigen() decomposition

$`values`

[1]  0.324323665 -0.000736292 -0.001210406 -0.015776132



Based on the above response modeling and ranges of the factors (4https://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] Retrievable results in a procedure

2018-12-25 Thread Steven Yen
Thanks Sarah. Below, replacing "structure" with "invisible" does 
wonders--that serves my need. What I want is quite simple - I call a 
procedure and it does two things: (1) display results for all; (2) save 
retrievable results for use in further analysis, e.g., in knitr. 
Earlier, with "structure" (or with results<-list(...)) it spits out the 
main results, with components repeated (printed) in a painfully long 
list. Yet, as I said, calling with foo<-try(...) prints the main results 
with the list suppressed. I am just looking for option to NOT have to 
call with foo<- always. There must be more ways to do this, but I am 
happy with invisible. Thanks again.


On 12/25/2018 11:10 PM, Sarah Goslee wrote:
> I'm a bit confused about what you actually want, but I think 
> invisible() might be the answer.
>
> Note that there's already a base function try() so that's not a great 
> name for test functions.
>
> Sarah
>
> On Tue, Dec 25, 2018 at 8:47 AM Steven Yen  > wrote:
>
> I would like to suppressed printing of retrievable results in a
> procedure and to print only when retrieved.
>
> In line 10 below I call procedure "try" and get matrices A,B,C all
> printed upon a call to the procedure. I get around this unwanted
> printing by calling with v<-try(A,B) as in line 11.
>
> Any way to suppress printing of the retrievable results listed in the
> structure command? Thank you, and Merry Christmas to all.
>
>
> A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T)
> B<-diag(4)
>
> try<-function(A,B){
>   C<-A+B
>   cat("\nC:\n"); print(C)
> structure(list(A=A,B=B,C=C))
> }
>
> try(A,B)# line 10
> v<-try(A,B) # line 11
>
> -- 
> st...@ntu.edu.tw  (S.T. Yen)
>
>
> [[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.
>
> -- 
> Sarah Goslee (she/her)
> http://www.sarahgoslee.com

-- 
st...@ntu.edu.tw (S.T. Yen)


[[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] fields package question

2018-12-25 Thread M P
Actually, let's set it
grid_new.l <- list(abcissa=c(-15.0,-14.5),ordinate=y)
to avoid out of bounds

On Tue, Dec 25, 2018 at 4:41 PM M P  wrote:

> Thanks, Eric, for looking into that.
> The values are below and since I subset the new abcissa  is smaller range
> grid_new.l <- list(abcissa=c(-15.0,-14.),ordinate=y)
> I am emailing form gmail - don't know why is using html to format when all
> is in ascii
>
> x
>  [1] -15.20180 -15.01948 -14.86533 -14.73180 -14.61402 -14.50866 -14.41335
>  [8] -14.32634 -14.24629 -14.17219
> y
>  [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45
> z
> [5,] 0.6467642 0.6467642 0.6467642 0.6467642 0.6467642 0.6467642 0.6467642
>  [6,] 0.5597143 0.5597143 0.5597143 0.5597143 0.5597143 0.5597143 0.5597143
>  [7,] 0.4854133 0.4854133 0.4854133 0.4854133 0.4854133 0.4854133 0.4854133
>  [8,] 0.4278326 0.4278326 0.4278326 0.4278326 0.4278326 0.4278326 0.4278326
>  [9,] 0.3834149 0.3834149 0.3834149 0.3834149 0.3834149 0.3834149 0.3834149
> [10,] 0.3433031 0.3433031 0.3433031 0.3433031 0.3433031 0.3433031 0.3433031
>[,8]  [,9] [,10]
>  [1,] 1.1900951 1.1900951 1.1900951
>  [2,] 1.0636935 1.0636935 1.0636935
>  [3,] 0.8927228 0.8927228 0.8927228
>  [4,] 0.7554456 0.7554456 0.7554456
>  [5,] 0.6467642 0.6467642 0.6467642
>  [6,] 0.5597143 0.5597143 0.5597143
>  [7,] 0.4854133 0.4854133 0.4854133
>  [8,] 0.4278326 0.4278326 0.4278326
>  [9,] 0.3834149 0.3834149 0.3834149
> [10,] 0.3433031 0.3433031 0.3433031
>
>
>
> On Tue, Dec 25, 2018 at 12:45 AM Eric Berger 
> wrote:
>
>> Since you don't provide lambda, rh or qext it is impossible to reproduce
>> what you are seeing.
>> Also note that in this mailing list HTML formatted emails are not passed
>> along.
>>
>>
>>
>> On Tue, Dec 25, 2018 at 4:13 AM M P  wrote:
>>
>>> Hello,
>>> I used commands below to obtain a surface, can plot it and all looks as
>>> expected.
>>> How do I evaluate values at new point. I tried as below but that produces
>>> errors.
>>> Thanks for suggestions/help.
>>>
>>> x <- log(lambda)
>>> y <- rh
>>> z <- qext[,,2]
>>>
>>> grid.l <- list(abcissa=x,ordinate=y)
>>> xg <- make.surface.grid(grid.l)
>>> out.p <- as.surface(xg,z)
>>> plot.surface(out.p,type="p")
>>>
>>> tried:
>>> grid_new.l <- list(abcissa=c(-15.0,-10.),ordinate=y)
>>> xg_new <- make.surface.grid(grid_new.l)
>>>
>>> out_new.p <- predict.surface(out.p,xg_new)
>>>
>>> results in this prompt:
>>> predict.surface is now the function predictSurface>
>>>
>>> [[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] fields package question

2018-12-25 Thread M P
Thanks, Eric, for looking into that.
The values are below and since I subset the new abcissa  is smaller range
grid_new.l <- list(abcissa=c(-15.0,-14.),ordinate=y)
I am emailing form gmail - don't know why is using html to format when all
is in ascii

x
 [1] -15.20180 -15.01948 -14.86533 -14.73180 -14.61402 -14.50866 -14.41335
 [8] -14.32634 -14.24629 -14.17219
y
 [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45
z
[5,] 0.6467642 0.6467642 0.6467642 0.6467642 0.6467642 0.6467642 0.6467642
 [6,] 0.5597143 0.5597143 0.5597143 0.5597143 0.5597143 0.5597143 0.5597143
 [7,] 0.4854133 0.4854133 0.4854133 0.4854133 0.4854133 0.4854133 0.4854133
 [8,] 0.4278326 0.4278326 0.4278326 0.4278326 0.4278326 0.4278326 0.4278326
 [9,] 0.3834149 0.3834149 0.3834149 0.3834149 0.3834149 0.3834149 0.3834149
[10,] 0.3433031 0.3433031 0.3433031 0.3433031 0.3433031 0.3433031 0.3433031
   [,8]  [,9] [,10]
 [1,] 1.1900951 1.1900951 1.1900951
 [2,] 1.0636935 1.0636935 1.0636935
 [3,] 0.8927228 0.8927228 0.8927228
 [4,] 0.7554456 0.7554456 0.7554456
 [5,] 0.6467642 0.6467642 0.6467642
 [6,] 0.5597143 0.5597143 0.5597143
 [7,] 0.4854133 0.4854133 0.4854133
 [8,] 0.4278326 0.4278326 0.4278326
 [9,] 0.3834149 0.3834149 0.3834149
[10,] 0.3433031 0.3433031 0.3433031



On Tue, Dec 25, 2018 at 12:45 AM Eric Berger  wrote:

> Since you don't provide lambda, rh or qext it is impossible to reproduce
> what you are seeing.
> Also note that in this mailing list HTML formatted emails are not passed
> along.
>
>
>
> On Tue, Dec 25, 2018 at 4:13 AM M P  wrote:
>
>> Hello,
>> I used commands below to obtain a surface, can plot it and all looks as
>> expected.
>> How do I evaluate values at new point. I tried as below but that produces
>> errors.
>> Thanks for suggestions/help.
>>
>> x <- log(lambda)
>> y <- rh
>> z <- qext[,,2]
>>
>> grid.l <- list(abcissa=x,ordinate=y)
>> xg <- make.surface.grid(grid.l)
>> out.p <- as.surface(xg,z)
>> plot.surface(out.p,type="p")
>>
>> tried:
>> grid_new.l <- list(abcissa=c(-15.0,-10.),ordinate=y)
>> xg_new <- make.surface.grid(grid_new.l)
>>
>> out_new.p <- predict.surface(out.p,xg_new)
>>
>> results in this prompt:
>> predict.surface is now the function predictSurface>
>>
>> [[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] Retrievable results in a procedure

2018-12-25 Thread Jeff Newmiller
You can use `capture.output`, but a far, far better solution is to remove the 
output statements from your computation functions entirely and let the caller 
decide whether to print the results.

You can, for example, add a `debug` parameter to the function, and if true it 
can return a list of as many intermediate results as you like that you can 
examine as you wish.

Of course, if debugging is your goal then learning to use the debug function to 
mark functions for single-stepping as needed is even better.

But no matter what, making functions that do both computation and output is 
really poor practice... do one or the other.

On December 25, 2018 5:42:13 AM PST, Steven Yen  wrote:
>I would like to suppressed printing of retrievable results in a 
>procedure and to print only when retrieved.
>
>In line 10 below I call procedure "try" and get matrices A,B,C all 
>printed upon a call to the procedure. I get around this unwanted 
>printing by calling with v<-try(A,B) as in line 11.
>
>Any way to suppress printing of the retrievable results listed in the 
>structure command? Thank you, and Merry Christmas to all.
>
>
>A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T)
>B<-diag(4)
>
>try<-function(A,B){
>  C<-A+B
>  cat("\nC:\n"); print(C)
>structure(list(A=A,B=B,C=C))
>}
>
>try(A,B)# line 10
>v<-try(A,B) # line 11

-- 
Sent from my phone. Please excuse my brevity.

__
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] Problem with Kruskal–Wallis test

2018-12-25 Thread Bert Gunter
"So, I'm not an expert in R and statistics" 

So you need to seek local help from someone who is. Statistics is usually
off-topic for this list -- it is about R programming primarily. And online
is probably not a good venue for the sort of discussion you need anyway.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Dec 25, 2018 at 5:37 AM Giuseppe Cillis  wrote:

> Dear Michael,
> Thanks for your answer.
> So, I'm not an expert in R and statistics, how can I create this interval
> of confidence of groups?
> Thanks
> Gc
>
> Il giorno sab 22 dic 2018, 13:34 Michael Dewey 
> ha
> scritto:
>
> > Dear Giuseppe
> >
> > If I understand you correctly you have a very large sample size so it is
> > not surprising that you get very small p-values. Eevn a scientifically
> > uninteresting difference can become statistically significant with large
> > samples. You probably need to define a metric for meaningful differences
> > between groups and calculate a confidence interval for it.
> >
> > Michael
> >
> > On 21/12/2018 15:37, Giuseppe Cillis wrote:
> > > Dear all,
> > > I am a beginner with R (and also with the statistics) for which I hope
> to
> > > be clear.
> > > I should do this non-parametric test on data I extracted from maps.
> > > In practice I have a column that represents the landscape Dynamics of a
> > > certain time period (there are 3 dynamics, each of them marked by the
> > > number 1, 2 or 3) and the other column with the values of a topographic
> > > variable (for example the slope) . In all, there are more than 90,000
> > pairs
> > > of values.
> > > Going to do the test in R, for all the dynamics and for all the
> > variables,
> > > I get out of the values of chi-square elevated (even in the order of
> > > thousands) and a p-value always <2.2e-16  why? Where can the error
> > be? in
> > > the script or in the test approach?
> > > Thanks in advance
> > >
> > >   [[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
> >
>
> [[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] Retrievable results in a procedure

2018-12-25 Thread Sarah Goslee
I'm a bit confused about what you actually want, but I think invisible()
might be the answer.

Note that there's already a base function try() so that's not a great name
for test functions.

Sarah

On Tue, Dec 25, 2018 at 8:47 AM Steven Yen  wrote:

> I would like to suppressed printing of retrievable results in a
> procedure and to print only when retrieved.
>
> In line 10 below I call procedure "try" and get matrices A,B,C all
> printed upon a call to the procedure. I get around this unwanted
> printing by calling with v<-try(A,B) as in line 11.
>
> Any way to suppress printing of the retrievable results listed in the
> structure command? Thank you, and Merry Christmas to all.
>
>
> A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T)
> B<-diag(4)
>
> try<-function(A,B){
>   C<-A+B
>   cat("\nC:\n"); print(C)
> structure(list(A=A,B=B,C=C))
> }
>
> try(A,B)# line 10
> v<-try(A,B) # line 11
>
> --
> st...@ntu.edu.tw (S.T. Yen)
>
>
> [[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.
>
-- 
Sarah Goslee (she/her)
http://www.sarahgoslee.com

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


[R] Retrievable results in a procedure

2018-12-25 Thread Steven Yen
I would like to suppressed printing of retrievable results in a 
procedure and to print only when retrieved.

In line 10 below I call procedure "try" and get matrices A,B,C all 
printed upon a call to the procedure. I get around this unwanted 
printing by calling with v<-try(A,B) as in line 11.

Any way to suppress printing of the retrievable results listed in the 
structure command? Thank you, and Merry Christmas to all.


A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T)
B<-diag(4)

try<-function(A,B){
  C<-A+B
  cat("\nC:\n"); print(C)
structure(list(A=A,B=B,C=C))
}

try(A,B)# line 10
v<-try(A,B) # line 11

-- 
st...@ntu.edu.tw (S.T. Yen)


[[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] Problem with Kruskal–Wallis test

2018-12-25 Thread Giuseppe Cillis
Dear Michael,
Thanks for your answer.
So, I'm not an expert in R and statistics, how can I create this interval
of confidence of groups?
Thanks
Gc

Il giorno sab 22 dic 2018, 13:34 Michael Dewey  ha
scritto:

> Dear Giuseppe
>
> If I understand you correctly you have a very large sample size so it is
> not surprising that you get very small p-values. Eevn a scientifically
> uninteresting difference can become statistically significant with large
> samples. You probably need to define a metric for meaningful differences
> between groups and calculate a confidence interval for it.
>
> Michael
>
> On 21/12/2018 15:37, Giuseppe Cillis wrote:
> > Dear all,
> > I am a beginner with R (and also with the statistics) for which I hope to
> > be clear.
> > I should do this non-parametric test on data I extracted from maps.
> > In practice I have a column that represents the landscape Dynamics of a
> > certain time period (there are 3 dynamics, each of them marked by the
> > number 1, 2 or 3) and the other column with the values of a topographic
> > variable (for example the slope) . In all, there are more than 90,000
> pairs
> > of values.
> > Going to do the test in R, for all the dynamics and for all the
> variables,
> > I get out of the values of chi-square elevated (even in the order of
> > thousands) and a p-value always <2.2e-16  why? Where can the error
> be? in
> > the script or in the test approach?
> > Thanks in advance
> >
> >   [[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
>

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


[R] Fwd: Problem with Kruskal–Wallis test

2018-12-25 Thread Giuseppe Cillis
Dear all,
I am a beginner with R (and also with the statistics) for which I hope to
be clear.
I should do this non-parametric test on data I extracted from maps.
In practice I have a column that represents the landscape Dynamics of a
certain time period (there are 3 dynamics, each of them marked by the
number 1, 2 or 3) and the other column with the values of a topographic
variable (for example the slope) . In all, there are more than 90,000 pairs
of values.
Going to do the test in R, for all the dynamics and for all the variables,
I get out of the values of chi-square elevated (even in the order of
thousands) and a p-value always <2.2e-16  why? Where can the error be? in
the script or in the test approach?
Thanks in advance

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