Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Data Simulation

  • 31-07-2008 12:55pm
    #1
    Registered Users, Registered Users 2 Posts: 2


    OK so im doing my disertation and one part of it involves probibility analysis of a large amount of data with several variables, my tutor has advised me that monte carlo simulation or the latin hypercube offer the best methods of obtaining results. But heres the tricky bit i need to come up with another method of obtaining results,if any of you guys can think of a diiferent method i would be very grateful.

    Many thanks....


Comments

  • Registered Users, Registered Users 2 Posts: 2,481 ✭✭✭Fremen


    You'll have to be a bit more specific than that...


  • Registered Users, Registered Users 2 Posts: 230 ✭✭Blue Magic


    Does anybody here use R statistical package regularly?

    Having an issue with running the following Monte Carlo simulation loop...

    library(survival)
    library(VGAM)

    attach(leukemia)
    leuk.km = survfit(Surv(time,status)~x, data=leukemia)
    leuk.na = survfit(Surv(time,status)~x, data=leukemia, type="flem")

    # MC loop

    N = 100 # sample size
    M = 1000 # number of Monte Carlo repetitions
    sc.KM = matrix(0, nrow=M, ncol=N)
    sc.NA = matrix(0, nrow=M, ncol=N)
    xs = matrix(0, nrow=M, ncol=N)
    for(m in 1:M){
    # generate a sample of time points (without censoring) from Makeham model
    x = rmakeham(N, shape=0.001, scale=1.07, epsilon=0.001)
    xs[m,] = x
    # apply survival curve estimation using NA and KM
    out.KM = survfit(Surv(x)~1)
    out.NA = survfit(Surv(x)~1, type="flem")
    # store estimates
    sc.KM[m,] = out.KM$surv
    sc.NA[m,] = out.NA$surv
    }


    This is loop looking at the Kaplan-Meier and Nelson-Aalen lifetime survival estimators...

    The following error message keeps coming up for this loop in R:
    "Error in sc.KM[m, ] = out.KM$surv : number of items to replace is not a multiple of replacement length"


    Help!


  • Registered Users, Registered Users 2 Posts: 230 ✭✭Blue Magic


    Okay, I've workout how to complete the loop..

    # MC loop
    N = 100 # sample size
    M = 1000 # number of Monte Carlo repetitions
    sc.KM = matrix(0, nrow=M, ncol=N)
    sc.NA = matrix(0, nrow=M, ncol=N)
    xs = matrix(0, nrow=M, ncol=N)
    for(m in 1:M){
    # generate a sample of time points (without censoring) from Makeham model
    x = rmakeham(N, shape=1.05, scale=0.00002, epsilon=0.0005)
    xs[m,] = x
    # apply survival curve estimation using NA and KM
    out.KM = survfit(Surv(x)~1)
    out.NA = survfit(Surv(x)~1, type="flem")
    kmsurv = out.KM$surv
    nasurv = out.NA$surv
    if(length(kmsurv<N)){ kmsurv = c(kmsurv, rep(NA,N-length(kmsurv))) }
    if(length(nasurv<N)){ nasurv = c(nasurv, rep(NA,N-length(nasurv))) }
    sc.KM[m,] = kmsurv
    sc.NA[m,] = nasurv
    }


    Now, how do I generate a plot for the Makeham model?

    Any clue at all anyone?


Advertisement