Beauchamp:MCG Predict

From OpenWetWare

(Difference between revisions)
Jump to: navigation, search
(New page: == Estimating amounts of McGurk Fusion across Stimuli == ===System setup=== # Install [ GNU R ] # Download the [
m (System setup)
Line 3: Line 3:
===System setup===
===System setup===
# Install  [ GNU R ]
# Install  [ GNU R ]
# Download the [ CIMS CODE zip file]
# Download the [ MCG CODE zip file]
# Extract the zip file to your Desktop/ or other preferred location
# Extract the zip file to your Desktop/ or other preferred location

Revision as of 12:29, 22 November 2013


Estimating amounts of McGurk Fusion across Stimuli

System setup

  1. Install GNU R
  2. Download the MCG CODE zip file
  3. Extract the zip file to your Desktop/ or other preferred location

Data setup

The model code assumes the data are stored in a matrix format with rows as subjects and each column a separate stimulus. The first row is used as labels for the columns. Each cell stores the proportion of times the subject reported a fused perception for the given stimulus. If there are 20 subjects and 14 stimuli, the file will have 21 rows (1st row is header row) and 14 columns. See data.csv in the code pack for the data used in Magnotti & Beauchamp.

If you are unfamiliar with R, the best approach is to run through all the model building steps using the included data.csv file, and then try with your own data.

Program setup

We need to ensure R can find the data and code files

1. Launch R

2. Open the file fit_models.R: File-> Open Document

3. We need to make 4 changes before running the code. See the comments in the code file for additional direction

Set the path to be the location of the downloaded files. If you extracted the code pack to your desktop, the path may already be correct


Set the location of the data to be fit

  mcg_data = as.matrix(read.csv(file='data.csv') )

4. Run the setup code to make sure there are no errors

  1. Highlight lines XX through YY using the mouse
  2. Execute the code by using the R menu: Edit -> Execute

Fitting the model

Highlight and execute each of the following lines in turn

  cl = makeCluster(detectCores())
  # This takes about 15 seconds per repetition on a fast computer
  mcg.model = model_function(n.reps=256)

Model Parameters

  1. The resulting parameters for each model are saved to cims_out.csv and gauss_out.csv.
  2. The predicted values for each model are saved to cims_predicted.csv and gauss_predicted.csv.

Model Comparisons

Advanced Functions

We mention here some other useful functions for those comfortable analyzing data with the R language. These functions assume you have run all the code in the previous section. Intrepid users are encouraged to let the source be their guide.

Load previously fitted models

Obtain predicted values

Plot model fits

Obtain model fit statistics

Contact Information

If you run into trouble with any step, please contact me: john dot magnotti at gmail dot com. If the model fitting fails to converge for your dataset, you may need to send me at least a portion of the data so I can replicate the error.



This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

If you find this code useful, please cite our work:

Magnotti JF and Beauchamp MS (submitted). Individual Differences in Priors and Sensory Noise Explain Rates of McGurk Fusion Perception

Personal tools