Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9164121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:36:21+00:00 2026-06-17T14:36:21+00:00

i was trying to store my simulation output inside an array. I have written

  • 0

i was trying to store my simulation output inside an array. I have written the following code:

nsim=50
res=array(0,c(nsim,20,20))
for(i in 1:nsim) {
    cat("simul=",i,"\n")
    simulated = NULL
    stik.simulated = NULL
    simulated = rpp(....)
    stik.simulated = STIKhat(....)
    # from stik.simulated we will get $khat and $Ktheo and 
    # the dimension of stik.simulated$Khat-stik.simulated$Ktheo is 20 x 20
    res[i,,] = stik.simulated$Khat - stik.simulated$Ktheo  
}

But whenever the function is trying to store the output inside an array, I get the following error:

simul= 1 
Xrange is  20 40 
Yrange is  -20 20 
Doing quartic kernel
Error in res[, , i] = stik.simulated$Khat - stik.simulated$Ktheo : 
  subscript out of bounds

seeking your help. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:36:22+00:00Added an answer on June 17, 2026 at 2:36 pm

    I think you need to organize your code to avoid such errors. I assume you are using package stpp.

    First You create, a function which generate the matrix of each iteration; Try to test your function with many values.

    stick_diff <- function(u,v){
      u <- seq(0,u,by=1)
      v <- seq(0,v,by=1)
      simulated <- rpp(...)                    ## call here rpp with right parameters
      stik <- STIKhat(xyt=simulated$xyt,
                         dist=u, times=v, ...)
      stik$Khat-stik$Ktheo                     ## !! here if u#v you will have recycling!
    }
    

    Once you are sure of your function you call it the loop, with right dimensions.

    nsim <- 50
    u    <- 20
    res=array(0,c(nsim,u,u))
    for(i in 1:nsim)
      res[i,,] <- stick_diff(i,u,u)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a typical definition/instance situation in my data modeling. I'm trying to store
I'm trying to store several 2D sprites inside a single texture, since I figured
I was trying to use a plist to store an array with the below
I am trying to develop a solution to following problem. I need to store
I am trying to add asynchronous output to a my program. Currently, I have
Situation: I'm trying run an https store (xcart) under one domain secure.example.com and I
Im trying to store a list,collection of data objects in Hbase. For example ,a
I am trying to store a byteArrayInputStream as File on a FTP Server .
I'm trying to store and retrieve numbers in android so later I can do
I'm trying to store an image into an SQL database without using temporary files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.