ReplicaX: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Answer: example run link added)
(argument params updated)
 
(3 intermediate revisions by the same user not shown)
Line 13: Line 13:


Rcode ReplicaX by Juha Karvanen does exactly that.
Rcode ReplicaX by Juha Karvanen does exactly that.
{{argument|relat1=attack|id=arg1500|type=truth|content=Table data cannot be pasted to the code for some reason.|sign=--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 11:33, 18 November 2018 (UTC)}}
<rcode label="Save a replica of your data" variables="
  name:vartype|description:Give the variable types in format c('discrete','continuous')|type:default|
  name:k|description:Give the k parameter (default recommended)|default:5|
  name:osigma|description:Give the osigma parameter (default recommended)|default:0.5|
  name:verbose|description:Do you want to show the replica data on screen?|type:selection|options:FALSE;No, only save;TRUE;Yes, show and save|default:FALSE
">
#  name:dat|description:Copy your data table here|type:table| Causes an error.
library(OpasnetUtils)
library(Lmoments)
library(bayesm)
library(MASS)
library(plyr)
library(compiler)
objects.latest("Op_en6248", code_name = "initiate") # Fetch the ReplicaX functions
enableJIT(3)
set.seed(20131103) #to reproduce the results
#Generating replica data
for(i in (1:ncol(dat))[vartype == 'continuous']) {
colnames(dat)[i] <- levels(dat[[i]])[dat[[1 , i]]]
dat[[i]] <- as.numeric(levels(dat[[i]])[dat[[i]]])
}
dat <- dat[2:nrow(dat) , ]
replica <- ReplicaX(dat, vartype, k = k, osigma = osigma)
objects.put(replica)
cat("The replica table is saved. Save the key of the model run to retrieve your data.\n")
if(verbose) {
cat("Copy the replica data from here.\n")
oprint(replica)
} else {
cat("Your replica data looks like this:\n")
oprint(head(replica))
}
</rcode>


[http://en.opasnet.org/en-opwiki/index.php/Special:R-tools?id=E9oTrZdmp563kVIx Show example data and analysis] (Making a new run takes ca. 4 minutes)
[http://en.opasnet.org/en-opwiki/index.php/Special:R-tools?id=E9oTrZdmp563kVIx Show example data and analysis] (Making a new run takes ca. 4 minutes)
Line 127: Line 176:
==Rationale==
==Rationale==


===Functions===
===Calculations===


Replica R function by Juha Karvanen does exactly that.
Replica R function by Juha Karvanen does exactly that.
Line 337: Line 386:
)
)


cat("Saved objects ReplicaX,  
cat("Saved objects ReplicaX, replica_discrete, new_obs2, which.maxk, observation_similarity, navar, rowwise_similarity, kernelCDF,
replica_discrete,  
  replica_continuous. Remember to load packages Lmoments, bayesm, MASS, plyr, and compiler before using ReplicaX.\n")
new_obs2,  
which.maxk,  
observation_similarity,  
navar,  
rowwise_similarity,  
kernelCDF,  
replica_continuous. Remember to load packages Lmoments, bayesm, MASS, plyr, and compiler before using ReplicaX.\n")
 
</rcode>
</rcode>



Latest revision as of 13:30, 1 February 2019



Question

How to generate an artificial data from a real data in such a way that

  • individuals are no longer identifiable from the data,
  • the marginal distributions are close to those of the original data,
  • the correlation structure is close to that of the original data?

Answer

Rcode ReplicaX by Juha Karvanen does exactly that.

⇤--arg1500: . Table data cannot be pasted to the code for some reason. --Jouni (talk) 11:33, 18 November 2018 (UTC) (type: truth; paradigms: science: attack)

Give the variable types in format c('discrete','continuous'):

Give the k parameter (default recommended):

Give the osigma parameter (default recommended):

Do you want to show the replica data on screen?:

+ Show code


Show example data and analysis (Making a new run takes ca. 4 minutes)

+ Show code

Rationale

Calculations

Replica R function by Juha Karvanen does exactly that.

+ Show code

See also

Keywords

References