# Linear spatial regression of Sentinel-2 products?

I would like to run a spatial regression to refine the spatial resolution of Sentinel-2 20 m bands by using the 10 m 8A band. So the idea is to have Bands at 20 m as dependent variables and band 8 A as the explanatory variable. I believe I should not use reducers as follow in the code because it is an image and not an image collection. Any tips on how to do that?

``````//Mascara do Cerrado
var polygon = ee.FeatureCollection('ft:1T3PyuGkCwptQjf5MZ5POd1iJJ330kUZU-avcjpT-');

var bands_MSI = ['B2', 'B3', 'B4', 'B8', 'B5', 'B6', 'B7', 'B8A', 'B11', 'B12'];

//Mascara de nuvens
var col_noclouds = function(image){
var quality = image.select('QA60');
var cloud01 = quality.eq(1);//Densas
var cloud02 = quality.eq(2);// Cirrus
var mask = cloud01.or(cloud02).not();

var base_collection = ee.ImageCollection('COPERNICUS/S2')
.filter(ee.Filter.lt('CLOUD_COVERAGE_ASSESSMENT', 5))
.filterBounds(polygon)
.filterDate('2017-01-01', '2017-12-31')
.map(col_noclouds)
.select(bands_MSI)
.median()
.select('B8','B12');

// Compute robust linear regression coefficients.
var robustLinearRegression = base_collection.reduce(
ee.Reducer.robustLinearRegression({
numX: 1,
numY: 1
}));

// The results are array images that must be flattened for display.
// These lists label the information along each axis of the arrays.
var bandNames = [['B8'], // 0-axis variation.
['B12']]; // 1-axis variation.

var rlrImage = robustLinearRegression.select(['coefficients']).arrayFlatten(bandNames);

// Display the OLS results.
Map.setCenter(-100.11, 40.38, 5);