[SOLVED] Calculate the mean and stdev for simulations

If you have problems using RGeostats package or if you simply need some help on an unlisted subject.

[SOLVED] Calculate the mean and stdev for simulations

Postby leminhson » Tue Jul 20, 2021 9:47 am

After performing several simulations, we can calculate the mean and standard deviations of all simulations by following commands:
Code: Select all
grid.db = db.stat.simu(grid.db,names="Raw.Simu.Gaussian.Z1*",fun="mean")

Code: Select all
grid.db = db.stat.simu(grid.db,names="Raw.Simu.Gaussian.Z1*",fun="stdv")


The problem is: for rows of simulations with NA values, their mean and standard deviation become zero
error.png
error.png (38.46 KiB) Viewed 10933 times

The zero values for NA rows could be misunderstood with the rows of actual zero values.
In my opinion, the value of mean and standard deviation for those NA rows should be NA, not zero.
leminhson
 
Posts: 2
Joined: Fri Jul 16, 2021 2:43 am

Re: Calculate the mean and standard deviation for simulation

Postby Didier Renard » Wed Jul 21, 2021 1:20 pm

As I mentioned to you (over a private mail ... where I strongly recommanded to use this forum from now on), the problem as been checked. We agree on the fact that the programming option which has been taken (considering that any stat based on a series of NA values...should give 0) is not the best choice. This will be fixed in future version.

In the mean time, we suggested to get around this problem performing this statistical evaluation "by hand". As a matter of fact, a set of variables contained in a Db can be extracted in the form of a data frame using db[,"names"] instruction (where 'names' stands for the names of the list of variables of interest).
Then it is reasonably easy to perform an operation on the lines or columns of this data frame (here you want to "compare" the different variables, i.e. the different columns of the data frame) using the "apply" function of R.
The resulting new vector can simply be added to the Db afterwards (using db.add).

Hope this will help
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: Calculate the mean and standard deviation for simulation

Postby leminhson » Thu Jul 22, 2021 1:19 pm

Didier Renard wrote:a set of variables contained in a Db can be extracted in the form of a data frame using db[,"names"] instruction (where 'names' stands for the names of the list of variables of interest).
Then perform an operation on the lines or columns of this data frame (here you want to "compare" the different variables, i.e. the different columns of the data frame) using the "apply" function of R.

Thank you Dr. Didier Renard. I have already solved the problem using your instruction above.
leminhson
 
Posts: 2
Joined: Fri Jul 16, 2021 2:43 am


Return to Other Troubleshooting

Who is online

Users browsing this forum: No registered users and 3 guests

cron