Re: [R] please help me a little

2018-02-09 Thread Jeff Newmiller
I don't use coxphf, but it is generally a bad idea to reference variables via 
multiple environments (e.g. global and the data= argument in this case) 
directly from within a formula. Just use FAM138A.chr wherever you have used 
test[,6] and it should work. 
-- 
Sent from my phone. Please excuse my brevity.

On February 9, 2018 8:43:03 PM PST, "Ding, Yuan Chun"  wrote:
>Hi R Users,
>
>I am very frustrated with the following code. Please do me a favor to
>run it.
>
>after reading into the test data set (I also pasted the data set
>below), the first line of code for "res_coxphf" did not work and
>generated the error code below. but the other three line worked well.  
>the second line for "res_coxphf2" should be the same as the first line;
>I need to run more than 100 variables in a loop, so I want to do test[,
>i], that is why I want to use the first line.
>
>however, the fourth line for "res_coxphf_cnaRate " also worked well
>after I added one variable "cna.rate" to first line. Can you run them
>and tell me why the first line does not run correctly?
>
>please install coxphf package if you do not have it installed.
>
>Thank you very much!!!
>
>Ding
>
>test<-read.csv("data_coxphf.csv", head=T)
>res_coxphf <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE)
>~test[, 6], data=test)
>res_coxphf2 <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE)
>~ test$FAM138A.chr1, data=test)
>
>res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~
>test[, 6], data=test)
>res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test)
>
>
>> test<-read.csv("data_coxphf.csv", head=T)
>> res_coxphf <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test[, 6], data=test)
>Error in mm1[, !colInter, drop = FALSE] :
>  (subscript) logical subscript too long
>> res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE)
>~ test[, 6], data=test)
>> res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test)
>> res_coxphf2 <- coxphf(formula=Surv(RFS_days2,
>OV_Had_a_Recurrence_CODE) ~ test$FAM138A.chr1, data=test)
>>
>
>
>
>id  cna.rateRFS_days2   OV_Had_a_Recurrence_CODE   
>DDX11L1.chr1FAM138A.chr1FAM138F.chr1
>sn1 150 560 1   0   0   0
>sn10216 581 1   0   0   0
>sn11191 455 1   0   0   0
>sn12135 118 1   0   0   0
>sn13199 25500   0   0   0
>sn14312 477 1   0   0   0
>sn15260 216 1   0   0   0
>sn16400 10561   0   0   0
>sn17350 398 1   1   1   1
>sn18324 583 1   0   0   0
>sn19174 136 1   0   0   0
>sn20262 98  1   0   0   0
>sn21172 516 1   0   0   0
>sn22490 14391   0   0   0
>sn23165 365 1   0   0   0
>sn24185 168 1   0   0   0
>sn25396 16631   0   0   0
>sn26240 299 1   0   0   0
>sn27114 29170   0   0   0
>sn28128 50  1   0   0   0
>sn29190 654 1   0   0   0
>sn3 435 429 1   0   0   0
>sn30268 31  1   0   0   0
>sn31175 34070   0   0   0
>sn32248 277 1   0   0   0
>sn33116 306 1   0   0   0
>sn34122 52  1   0   0   0
>sn35222 77  1   0   0   0
>sn36414 242 1   0   0   0
>sn37300 10341   1   1   1
>sn38268 32980   0   0   0
>sn4 556 24240   0   0   0
>sn40274 201 1   0   0   0
>sn41267 268 1   0   0   0
>sn42325 147 1   0   0   0
>sn43323 26110   0   0   0
>sn44115 573 1   0   0   0
>sn45265 215 1   0   0   0
>sn48129 259 1   0   0   0
>sn5 114 183 1   0   0   0
>sn51183 219 1   0   0   0
>sn52314 271 1   0   0   0
>sn53465 20710   0   0   0
>sn54207 44  1   0   0   0
>sn55321 347 1   0   0   0
>sn56217 12570   0   0   0
>sn57209 262 1   0   0   0
>sn58227 18110   0   0   0
>sn59130 463 1   0   0   0
>sn6 320 306 1   0   0   0
>sn60136 456 1   0   0   0
>sn62208 48  1   0   0   0
>sn63253 452 1   0  

Re: [R] How to label a polygon window (spatstat package)

2018-02-09 Thread Mohammad Tanvir Ahamed via R-help
Thanks.
when there is multiple polygon , it a problem .
looking for something more .

Regards.
Tanvir Ahamed 
Stockholm, Sweden |  mashra...@yahoo.com 






On Saturday, February 10, 2018, 6:35:59 AM GMT+1, Michael Sumner 
 wrote: 





Try

text(0.5, 0.5, label = "?text") 

On Sat, 10 Feb 2018, 16:22 Mohammad Tanvir Ahamed via R-help, 
 wrote:
> Hi, 
> I want to label a polygon (circle or polygon) inside.
> As for example code 
> 
> library(spatstat)
> x <- runif(20)
> y <- runif(20)
> X <- ppp(x, y, window=disc(0.7))
> plot(X)
> 
> Now I want to label that circle inside . Can some one please help me ? 
> Thanks. 
> 
> Regards.
> Tanvir Ahamed
> Stockholm, Sweden |  mashra...@yahoo.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.
> 


-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

__
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 label a polygon window (spatstat package)

2018-02-09 Thread Michael Sumner
Try

text(0.5, 0.5, label = "?text")

On Sat, 10 Feb 2018, 16:22 Mohammad Tanvir Ahamed via R-help, <
r-help@r-project.org> wrote:

> Hi,
> I want to label a polygon (circle or polygon) inside.
> As for example code
>
> library(spatstat)
> x <- runif(20)
> y <- runif(20)
> X <- ppp(x, y, window=disc(0.7))
> plot(X)
>
> Now I want to label that circle inside . Can some one please help me ?
> Thanks.
>
> Regards.
> Tanvir Ahamed
> Stockholm, Sweden |  mashra...@yahoo.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.
>


-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

[[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] How to label a polygon window (spatstat package)

2018-02-09 Thread Mohammad Tanvir Ahamed via R-help
Hi, 
I want to label a polygon (circle or polygon) inside.
As for example code 

library(spatstat)
x <- runif(20)
y <- runif(20)
X <- ppp(x, y, window=disc(0.7))
plot(X)

Now I want to label that circle inside . Can some one please help me ? 
Thanks. 

Regards.
Tanvir Ahamed 
Stockholm, Sweden |  mashra...@yahoo.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.


[R] please help me a little

2018-02-09 Thread Ding, Yuan Chun
Hi R Users,

I am very frustrated with the following code. Please do me a favor to run it.

after reading into the test data set (I also pasted the data set below), the 
first line of code for "res_coxphf" did not work and generated the error code 
below. but the other three line worked well.   the second line for 
"res_coxphf2" should be the same as the first line; I need to run more than 100 
variables in a loop, so I want to do test[, i], that is why I want to use the 
first line.

however, the fourth line for "res_coxphf_cnaRate " also worked well after I 
added one variable "cna.rate" to first line. Can you run them and tell me why 
the first line does not run correctly?

please install coxphf package if you do not have it installed.

Thank you very much!!!

Ding

test<-read.csv("data_coxphf.csv", head=T)
res_coxphf <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~test[, 
6], data=test)
res_coxphf2 <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ 
test$FAM138A.chr1, data=test)

res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ test[, 
6], data=test)
res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) 
~ test[, 6]+ cna.rate, data=test)


> test<-read.csv("data_coxphf.csv", head=T)
> res_coxphf <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ 
> test[, 6], data=test)
Error in mm1[, !colInter, drop = FALSE] :
  (subscript) logical subscript too long
> res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ test[, 
> 6], data=test)
> res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2, 
> OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test)
> res_coxphf2 <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ 
> test$FAM138A.chr1, data=test)
>



id  cna.rateRFS_days2   OV_Had_a_Recurrence_CODE
DDX11L1.chr1FAM138A.chr1FAM138F.chr1
sn1 150 560 1   0   0   0
sn10216 581 1   0   0   0
sn11191 455 1   0   0   0
sn12135 118 1   0   0   0
sn13199 25500   0   0   0
sn14312 477 1   0   0   0
sn15260 216 1   0   0   0
sn16400 10561   0   0   0
sn17350 398 1   1   1   1
sn18324 583 1   0   0   0
sn19174 136 1   0   0   0
sn20262 98  1   0   0   0
sn21172 516 1   0   0   0
sn22490 14391   0   0   0
sn23165 365 1   0   0   0
sn24185 168 1   0   0   0
sn25396 16631   0   0   0
sn26240 299 1   0   0   0
sn27114 29170   0   0   0
sn28128 50  1   0   0   0
sn29190 654 1   0   0   0
sn3 435 429 1   0   0   0
sn30268 31  1   0   0   0
sn31175 34070   0   0   0
sn32248 277 1   0   0   0
sn33116 306 1   0   0   0
sn34122 52  1   0   0   0
sn35222 77  1   0   0   0
sn36414 242 1   0   0   0
sn37300 10341   1   1   1
sn38268 32980   0   0   0
sn4 556 24240   0   0   0
sn40274 201 1   0   0   0
sn41267 268 1   0   0   0
sn42325 147 1   0   0   0
sn43323 26110   0   0   0
sn44115 573 1   0   0   0
sn45265 215 1   0   0   0
sn48129 259 1   0   0   0
sn5 114 183 1   0   0   0
sn51183 219 1   0   0   0
sn52314 271 1   0   0   0
sn53465 20710   0   0   0
sn54207 44  1   0   0   0
sn55321 347 1   0   0   0
sn56217 12570   0   0   0
sn57209 262 1   0   0   0
sn58227 18110   0   0   0
sn59130 463 1   0   0   0
sn6 320 306 1   0   0   0
sn60136 456 1   0   0   0
sn62208 48  1   0   0   0
sn63253 452 1   0   0   0
sn64326 282 1   0   0   0
sn67260 229 1   0   0   0
sn68329 661 0   0   0   0
sn69478 44  1   0   0   0
sn7 263 582 1   0   0   0
sn70309 741 1   0   0   0
sn8 223 10700   0   0   0
sn9 211 216 1   0   0   0


---

[R] Covariates in fuzzy RDD with rddtools

2018-02-09 Thread Chiara Malavasi
Hello!
I am having trouble including covariates in a fuzzy RDD model in R with 
rddtools. I run the following commands:

library(rddtools)

data.complete2 <- as.data.frame(cbind(GDPpc.rel, GR.rate, 
fitval.firstStage)) colnames(data.complete2) <- c("GDPpc.rel", "GR.rate", 
"FitTreat")

data.RDD<-rdd_data(x=data.complete2$GDPpc.rel, y=data.complete2$GR.rate, 
z=data.complete2$FitTreat, covar=dummytime, cutpoint = 0.75)
data.RDD1<-rdd_data(x=data.complete2$GDPpc.rel, y=data.complete2$GR.rate, 
z=data.complete2$FitTreat, covar=cbind(dummytime, dummyreg), cutpoint = 0.75)

reg_para <- rdd_reg_lm(rdd_object=data.RDD, covar.opt = list(strategy= 
"include"), order = 4)
reg_para1 <- rdd_reg_lm(rdd_object=data.RDD1,  covar.opt = list(strategy = 
"include"), order = 4)

where dummytime and dummyreg are two dummy variables considering time and 
regional effects.

The problem is that looking at the summary of the two regressions, they seem to 
be exactly the same and the coefficient which should refer to the dummy 
variables is not reported. My guess is that I did not actually implement the 
covariates in the regression, but I cannot understand where is the problem. Any 
suggestion?

Thank you in advance.

Best regards,

Chiara Malavasi


[[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] Optim function returning always initial value for parameter to be optimized

2018-02-09 Thread ProfJCNash
Did you check the gradient? I don't think so. It's zero, so of course
you end up where you start.

Try

data.input= data.frame(state1 = (1:500), state2 = (201:700) )
err.th.scalar <- function(threshold, data){

state1 <- data$state1
state2 <- data$state2

op1l <- length(state1)
op2l <- length(state2)

op1.err <- sum(state1 <= threshold)/op1l
op2.err <- sum(state2 >= threshold)/op2l

total.err <- (op1.err + op2.err)

return(total.err)
}

soln <- optim(par = 300, fn=err.th.scalar, data = data.input, method =
"BFGS")
soln
require("numDeriv")
gtest <- grad(err.th.scalar, x=300, data = data.input)
gtest


On 2018-02-09 09:05 AM, BARLAS Marios 247554 wrote:
> data.input= data.frame(state1 = (1:500), state2 = (201:700) )
> 
> with data that partially overlap in terms of values. 
> 
> I want to minimize the assessment error of each state by using this function:
> 
> err.th.scalar <- function(threshold, data){
>   
>   state1 <- data$state1
>   state2 <- data$state2
>   
>   op1l <- length(state1)
>   op2l <- length(state2)
>   
>   op1.err <- sum(state1 <= threshold)/op1l
>   op2.err <- sum(state2 >= threshold)/op2l
>   
>   total.err <- (op1.err + op2.err)
> 
>   return(total.err)
> }
> 
> 
> SO I'm trying to minimize the total error. This Total Error should be a U 
> shape essentially.
> 
> 
> I'm using optim as follows: 
> 
> optim(par = 300, fn=err.th.scalar, data = data.input, method = "BFGS")


Maybe develop an analytic gradient if it is very small, as the numeric
approximation can then be zero even when the true gradient is not.

JN

__
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] Optim function returning always initial value for parameter to be optimized

2018-02-09 Thread BARLAS Marios 247554
Hello,

I'm trying to fminimize the following problem:

You have a data frame with 2 columns.

data.input= data.frame(state1 = (1:500), state2 = (201:700) )

with data that partially overlap in terms of values. 

I want to minimize the assessment error of each state by using this function:

err.th.scalar <- function(threshold, data){
  
  state1 <- data$state1
  state2 <- data$state2
  
  op1l <- length(state1)
  op2l <- length(state2)
  
  op1.err <- sum(state1 <= threshold)/op1l
  op2.err <- sum(state2 >= threshold)/op2l
  
  total.err <- (op1.err + op2.err)

  return(total.err)
}


SO I'm trying to minimize the total error. This Total Error should be a U shape 
essentially.


I'm using optim as follows: 

optim(par = 300, fn=err.th.scalar, data = data.input, method = "BFGS")

For some reason that's driving me crazy, in the first trial it worked but right 
now the output of optim for the parameter to get optimized is EXACTLY the same 
as the initial estimate whatever the initial estimate value is. 

Please, any ideas why ? 

I can't see the error at this moment.


Thanks in advance,
Marios Barlas
__
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] Convolutional neural networks (CNN) - build a model and After?

2018-02-09 Thread Karim Mezhoud
Hi,
I am learning CNN using MXNet R package. I am following this great tutorial
about olivetti_faces reconnaissance
.

In the end after building model and testing the final score was 0.975.
It is great score but what can do after with this model?
How can use this model for other set on images?
Is it used to recognize which person in the training data or classify new
images if it content faces or not?
Thanks
Karim

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